commit 5a542c3fcba6d3613399e2af601aefbf6e132de0
parent c2554f81b89130844f581fd23b6cb677cbc6e358
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
transaction. But "height" == -1 means transaction with unconfirmed
input. Changed code to use <= 0 instead which fixes this bug.
Diffstat:
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/electrumpersonalserver/server/transactionmonitor.py b/electrumpersonalserver/server/transactionmonitor.py
@@ -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
@@ -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][
@@ -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)
@@ -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])
@@ -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"],