Skip to content

Commit a4293c4

Browse files
committed
transaction: SPV-verify TxInput.block_height and .spent_height
1 parent b944371 commit a4293c4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

electrum/address_synchronizer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def get_addresses(self):
140140
def get_address_history(self, addr: str) -> Dict[str, int]:
141141
"""Returns the history for the address, as a txid->height dict.
142142
In addition to what we have from the server, this includes local and future txns.
143+
Note: heights are SPV-verified.
143144
144145
Also see related method db.get_addr_history, which stores the response from the server,
145146
so that only includes txns the server sees.
@@ -841,8 +842,8 @@ def get_tx_fee(self, txid: str) -> Optional[int]:
841842
@with_lock
842843
def get_addr_io(self, address: str):
843844
h = self.get_address_history(address).items()
844-
received = {}
845-
sent = {}
845+
received = {} # type: Dict[str, tuple[int, int, int, bool]]
846+
sent = {} # type: Dict[str, tuple[str, int, int]]
846847
for tx_hash, height in h:
847848
tx_mined_info = self.get_tx_height(tx_hash)
848849
txpos = tx_mined_info.txpos if tx_mined_info.txpos is not None else -1

electrum/transaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ def __init__(self, *,
336336
self.witness = witness
337337
self._is_coinbase_output = is_coinbase_output
338338
# blockchain fields
339-
self.block_height = None # type: Optional[int] # height at which the TXO is mined; None means unknown. not SPV-ed.
339+
self.block_height = None # type: Optional[int] # height at which the TXO is mined; None means unknown. SPV-ed.
340340
self.block_txpos = None # type: Optional[int] # position of tx in block, if TXO is mined; otherwise None or -1
341-
self.spent_height = None # type: Optional[int] # height at which the TXO got spent
341+
self.spent_height = None # type: Optional[int] # height at which the TXO got spent. SPV-ed.
342342
self.spent_txid = None # type: Optional[str] # txid of the spender
343343
self._utxo = None # type: Optional[Transaction]
344344
self.__scriptpubkey = None # type: Optional[bytes]

0 commit comments

Comments
 (0)