Browse Source

Merge pull request #7399 from SomberNight/202107_wallet_request_status_event

wallet: fire "request_status" event also when conf number changes
patch-4
ghost43 4 years ago
committed by GitHub
parent
commit
cf7f66e9e6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      electrum/address_synchronizer.py
  2. 20
      electrum/wallet.py

4
electrum/address_synchronizer.py

@ -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:

20
electrum/wallet.py

@ -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:

Loading…
Cancel
Save