tFix handling of txes with unconfirmed inputs - electrum-personal-server - Maximally lightweight electrum server for a single user HTML git clone https://git.parazyd.org/electrum-personal-server DIR Log DIR Files DIR Refs DIR README --- DIR commit 5a542c3fcba6d3613399e2af601aefbf6e132de0 DIR parent c2554f81b89130844f581fd23b6cb677cbc6e358 HTML Author: chris-belcher <chris-belcher@users.noreply.github.com> Date: Sat, 13 Apr 2019 02:26:17 +0100 Fix handling of txes with unconfirmed inputs Previous code assumed that only "height" == 0 meant unconfirmed ttransaction. But "height" == -1 means transaction with unconfirmed input. Changed code to use <= 0 instead which fixes this bug. Diffstat: M electrumpersonalserver/server/tran… | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- DIR diff --git a/electrumpersonalserver/server/transactionmonitor.py b/electrumpersonalserver/server/transactionmonitor.py t@@ -278,8 +278,8 @@ class TransactionMonitor(object): return new_history_element def sort_address_history_list(self, his): - unconfirm_txes = list(filter(lambda h:h["height"] == 0, his["history"])) - confirm_txes = filter(lambda h:h["height"] != 0, his["history"]) + unconfirm_txes = list(filter(lambda h:h["height"] <= 0, his["history"])) + confirm_txes = filter(lambda h:h["height"] > 0, his["history"]) #TODO txes must be "in blockchain order" # the order they appear in the block # it might be "blockindex" in listtransactions and gettransaction t@@ -307,7 +307,7 @@ class TransactionMonitor(object): + pprint.pformat(self.address_history)) logger.debug("unconfirmed txes = " + pprint.pformat(self.unconfirmed_txes)) - logger.debug("self.reorganizable_txes = " + logger.debug("reorganizable_txes = " + pprint.pformat(self.reorganizable_txes)) logger.debug("updated_scripthashes = " + str(updated_scrhashes)) updated_scrhashes = filter(lambda sh:self.address_history[sh][ t@@ -339,8 +339,8 @@ class TransactionMonitor(object): if tx["category"] != "orphan": #add to history as unconfirmed txd = self.rpc.call("decoderawtransaction", [tx["hex"]]) - new_history_element = self.generate_new_history_element(tx, - txd) + new_history_element = self.generate_new_history_element( + tx, txd) for scrhash in scrhashes: self.address_history[scrhash]["history"].append( new_history_element) t@@ -387,7 +387,7 @@ class TransactionMonitor(object): def check_for_confirmations(self): logger = self.logger tx_scrhashes_removed_from_mempool = [] - logger.debug("check4con unconfirmed_txes = " + logger.debug("unconfirmed_txes = " + pprint.pformat(self.unconfirmed_txes)) for uc_txid, scrhashes in self.unconfirmed_txes.items(): tx = self.rpc.call("gettransaction", [uc_txid]) t@@ -508,7 +508,7 @@ class TransactionMonitor(object): for scrhash in matching_scripthashes: self.address_history[scrhash]["history"].append( new_history_element) - if new_history_element["height"] == 0: + if new_history_element["height"] <= 0: self.unconfirmed_txes[tx["txid"]].append(scrhash) if tx["confirmations"] > 0: self.reorganizable_txes.append((tx["txid"], tx["blockhash"],