|
@ -207,11 +207,11 @@ class AddressSynchronizer(Logger): |
|
|
conflicting_txns -= {tx_hash} |
|
|
conflicting_txns -= {tx_hash} |
|
|
return conflicting_txns |
|
|
return conflicting_txns |
|
|
|
|
|
|
|
|
def add_transaction(self, tx_hash, tx: Transaction, allow_unrelated=False) -> bool: |
|
|
def add_transaction(self, tx: Transaction, allow_unrelated=False) -> bool: |
|
|
"""Returns whether the tx was successfully added to the wallet history.""" |
|
|
"""Returns whether the tx was successfully added to the wallet history.""" |
|
|
assert tx_hash, tx_hash |
|
|
|
|
|
assert tx, tx |
|
|
assert tx, tx |
|
|
assert tx.is_complete() |
|
|
assert tx.is_complete() |
|
|
|
|
|
tx_hash = tx.txid() |
|
|
# assert tx_hash == tx.txid() # disabled as expensive; test done by Synchronizer. |
|
|
# assert tx_hash == tx.txid() # disabled as expensive; test done by Synchronizer. |
|
|
# we need self.transaction_lock but get_tx_height will take self.lock |
|
|
# we need self.transaction_lock but get_tx_height will take self.lock |
|
|
# so we need to take that too here, to enforce order of locks |
|
|
# so we need to take that too here, to enforce order of locks |
|
@ -339,7 +339,7 @@ class AddressSynchronizer(Logger): |
|
|
|
|
|
|
|
|
def receive_tx_callback(self, tx_hash, tx, tx_height): |
|
|
def receive_tx_callback(self, tx_hash, tx, tx_height): |
|
|
self.add_unverified_tx(tx_hash, tx_height) |
|
|
self.add_unverified_tx(tx_hash, tx_height) |
|
|
self.add_transaction(tx_hash, tx, allow_unrelated=True) |
|
|
self.add_transaction(tx, allow_unrelated=True) |
|
|
|
|
|
|
|
|
def receive_history_callback(self, addr: str, hist, tx_fees: Dict[str, int]): |
|
|
def receive_history_callback(self, addr: str, hist, tx_fees: Dict[str, int]): |
|
|
with self.lock: |
|
|
with self.lock: |
|
@ -360,7 +360,7 @@ class AddressSynchronizer(Logger): |
|
|
tx = self.db.get_transaction(tx_hash) |
|
|
tx = self.db.get_transaction(tx_hash) |
|
|
if tx is None: |
|
|
if tx is None: |
|
|
continue |
|
|
continue |
|
|
self.add_transaction(tx_hash, tx, allow_unrelated=True) |
|
|
self.add_transaction(tx, allow_unrelated=True) |
|
|
|
|
|
|
|
|
# Store fees |
|
|
# Store fees |
|
|
for tx_hash, fee_sat in tx_fees.items(): |
|
|
for tx_hash, fee_sat in tx_fees.items(): |
|
@ -386,7 +386,7 @@ class AddressSynchronizer(Logger): |
|
|
continue |
|
|
continue |
|
|
tx = self.db.get_transaction(tx_hash) |
|
|
tx = self.db.get_transaction(tx_hash) |
|
|
if tx is not None: |
|
|
if tx is not None: |
|
|
self.add_transaction(tx_hash, tx, allow_unrelated=True) |
|
|
self.add_transaction(tx, allow_unrelated=True) |
|
|
|
|
|
|
|
|
def remove_local_transactions_we_dont_have(self): |
|
|
def remove_local_transactions_we_dont_have(self): |
|
|
for txid in itertools.chain(self.db.list_txi(), self.db.list_txo()): |
|
|
for txid in itertools.chain(self.db.list_txi(), self.db.list_txo()): |
|
@ -569,7 +569,7 @@ class AddressSynchronizer(Logger): |
|
|
def add_future_tx(self, tx: Transaction, num_blocks: int) -> None: |
|
|
def add_future_tx(self, tx: Transaction, num_blocks: int) -> None: |
|
|
assert num_blocks > 0, num_blocks |
|
|
assert num_blocks > 0, num_blocks |
|
|
with self.lock: |
|
|
with self.lock: |
|
|
self.add_transaction(tx.txid(), tx) |
|
|
self.add_transaction(tx) |
|
|
self.future_tx[tx.txid()] = num_blocks |
|
|
self.future_tx[tx.txid()] = num_blocks |
|
|
|
|
|
|
|
|
def get_tx_height(self, tx_hash: str) -> TxMinedInfo: |
|
|
def get_tx_height(self, tx_hash: str) -> TxMinedInfo: |
|
|