Browse Source

wallet.add_transaction: prevent channel backup from being added twice

patch-4
ThomasV 4 years ago
parent
commit
e93becf33a
  1. 7
      electrum/address_synchronizer.py
  2. 3
      electrum/wallet.py

7
electrum/address_synchronizer.py

@ -251,7 +251,12 @@ class AddressSynchronizer(Logger):
return conflicting_txns
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.
Note that a transaction may need to be added several times, if our
list of addresses has increased. This will return True even if the
transaction was already in self.db.
"""
assert tx, tx
# note: tx.is_complete() is not necessarily True; tx might be partial
# but it *needs* to have a txid:

3
electrum/wallet.py

@ -884,8 +884,9 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
return bool(labels)
def add_transaction(self, tx, *, allow_unrelated=False):
is_known = bool(self.db.get_transaction(tx.txid()))
tx_was_added = super().add_transaction(tx, allow_unrelated=allow_unrelated)
if tx_was_added:
if tx_was_added and not is_known:
self._maybe_set_tx_label_based_on_invoices(tx)
if self.lnworker:
self.lnworker.maybe_add_backup_from_tx(tx)

Loading…
Cancel
Save