wallet.add_transaction: prevent channel backup from being added twice
This commit is contained in:
@@ -251,7 +251,12 @@ class AddressSynchronizer(Logger):
|
|||||||
return conflicting_txns
|
return conflicting_txns
|
||||||
|
|
||||||
def add_transaction(self, 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.
|
||||||
|
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
|
assert tx, tx
|
||||||
# note: tx.is_complete() is not necessarily True; tx might be partial
|
# note: tx.is_complete() is not necessarily True; tx might be partial
|
||||||
# but it *needs* to have a txid:
|
# but it *needs* to have a txid:
|
||||||
|
|||||||
@@ -884,8 +884,9 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
|||||||
return bool(labels)
|
return bool(labels)
|
||||||
|
|
||||||
def add_transaction(self, tx, *, allow_unrelated=False):
|
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)
|
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)
|
self._maybe_set_tx_label_based_on_invoices(tx)
|
||||||
if self.lnworker:
|
if self.lnworker:
|
||||||
self.lnworker.maybe_add_backup_from_tx(tx)
|
self.lnworker.maybe_add_backup_from_tx(tx)
|
||||||
|
|||||||
Reference in New Issue
Block a user