transaction: SPV-verify TxInput.block_height and .spent_height
What changed, and why it matters
This commit only updates comments and type annotations in Electrum's code. It changes documentation strings to note that certain transaction height values are now SPV-verified (Simple Payment Verification), and adds Python type hints. No actual code behavior changes, so there is no security vulnerability introduced or fixed by this patch itself.
No action needed. This is a non-functional documentation/type-hint commit. If the SPV verification claim relates to a prior functional change, review that related commit separately.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies two files. In transaction.py, comments for TxInput.block_height and TxInput.spent_height are changed from ‘not SPV-ed’ to ‘SPV-ed’. In address_synchronizer.py, a docstring note is added that heights are SPV-verified, and type annotations are added for the received and sent dictionaries in get_addr_io. There are no functional code changes—only documentation and type hints.
Changed components
electrum/transaction.pyelectrum/address_synchronizer.pyInspect captured patch +5 / −4
diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py
index f501f68..a946426 100644
--- a/electrum/address_synchronizer.py
+++ b/electrum/address_synchronizer.py
@@ -140,6 +140,7 @@ class AddressSynchronizer(Logger, EventListener):
def get_address_history(self, addr: str) -> Dict[str, int]:
"""Returns the history for the address, as a txid->height dict.
In addition to what we have from the server, this includes local and future txns.
+ Note: heights are SPV-verified.
Also see related method db.get_addr_history, which stores the response from the server,
so that only includes txns the server sees.
@@ -841,8 +842,8 @@ class AddressSynchronizer(Logger, EventListener):
@with_lock
def get_addr_io(self, address: str):
h = self.get_address_history(address).items()
- received = {}
- sent = {}
+ received = {} # type: Dict[str, tuple[int, int, int, bool]]
+ sent = {} # type: Dict[str, tuple[str, int, int]]
for tx_hash, height in h:
tx_mined_info = self.get_tx_height(tx_hash)
txpos = tx_mined_info.txpos if tx_mined_info.txpos is not None else -1
diff --git a/electrum/transaction.py b/electrum/transaction.py
index 33040b7..7126e0c 100644
--- a/electrum/transaction.py
+++ b/electrum/transaction.py
@@ -336,9 +336,9 @@ class TxInput:
self.witness = witness
self._is_coinbase_output = is_coinbase_output
# blockchain fields
- self.block_height = None # type: Optional[int] # height at which the TXO is mined; None means unknown. not SPV-ed.
+ self.block_height = None # type: Optional[int] # height at which the TXO is mined; None means unknown. SPV-ed.
self.block_txpos = None # type: Optional[int] # position of tx in block, if TXO is mined; otherwise None or -1
- self.spent_height = None # type: Optional[int] # height at which the TXO got spent
+ self.spent_height = None # type: Optional[int] # height at which the TXO got spent. SPV-ed.
self.spent_txid = None # type: Optional[str] # txid of the spender
self._utxo = None # type: Optional[Transaction]
self.__scriptpubkey = None # type: Optional[bytes]
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.