1
0

wallet: fire "request_status" event also when conf number changes

This commit is contained in:
SomberNight
2021-07-11 16:57:01 +02:00
parent 5b627208f1
commit d94d443082
2 changed files with 21 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ from .util import profiler, bfh, TxMinedInfo, UnrelatedTransactionException, wit
from .transaction import Transaction, TxOutput, TxInput, PartialTxInput, TxOutpoint, PartialTransaction
from .synchronizer import Synchronizer
from .verifier import SPV
from .blockchain import hash_header
from .blockchain import hash_header, Blockchain
from .i18n import _
from .logging import Logger
@@ -591,7 +591,7 @@ class AddressSynchronizer(Logger):
with self.lock:
return dict(self.unverified_tx) # copy
def undo_verifications(self, blockchain, above_height):
def undo_verifications(self, blockchain: Blockchain, above_height: int) -> Set[str]:
'''Used by the verifier when a reorg has happened'''
txs = set()
with self.lock:

View File

@@ -2074,7 +2074,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
def delete_address(self, address: str) -> None:
raise Exception("this wallet cannot delete addresses")
def get_onchain_request_status(self, r):
def get_onchain_request_status(self, r: OnchainInvoice) -> Tuple[bool, Optional[int]]:
address = r.get_address()
amount = r.get_amount_sat()
received, sent = self.get_addr_io(address)
@@ -2231,6 +2231,24 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
def receive_tx_callback(self, tx_hash, tx, tx_height):
super().receive_tx_callback(tx_hash, tx, tx_height)
self._update_request_statuses_touched_by_tx(tx_hash)
def add_verified_tx(self, tx_hash, info):
super().add_verified_tx(tx_hash, info)
self._update_request_statuses_touched_by_tx(tx_hash)
def undo_verifications(self, blockchain, above_height):
reorged_txids = super().undo_verifications(blockchain, above_height)
for txid in reorged_txids:
self._update_request_statuses_touched_by_tx(txid)
def _update_request_statuses_touched_by_tx(self, tx_hash: str) -> None:
# FIXME in some cases if tx2 replaces unconfirmed tx1 in the mempool, we are not called.
# For a given receive request, if tx1 touches it but tx2 does not, then
# we were called when tx1 was added, but we will not get called when tx2 replaces tx1.
tx = self.db.get_transaction(tx_hash)
if tx is None:
return
for txo in tx.outputs():
addr = txo.address
if addr in self.receive_requests: