interface: remove prefix from donation addresses
What changed, and why it matters
This commit fixes a small bug where Electrum servers that include 'bitcoin:' in front of their donation address were being rejected as invalid. The change strips that prefix before checking the address. It is a minor usability fix for donations, not a serious security issue, though it does slightly tighten input validation by ensuring the server response is a string.
No urgent action needed. Treat as routine bug fix. Reviewers may verify that removeprefix('bitcoin:') handles only the intended BIP21 scheme prefix and does not introduce parsing issues with other URI components.
Security signals we found
Input validation added (isinstance str check)
URI prefix stripped before address validation
No hard-fail maintained for unrecognized future address types
Evidence from the diff
The patch modifies Interface._get_donation_address() in electrum/interface.py. It now strips a leading ‘bitcoin:’ URI prefix from server-provided donation addresses before validating them with bitcoin.is_address(). It also adds an isinstance(res, str) check and raises RequestCorrupted if the response is not a string. The previous behavior rejected valid addresses that included the prefix, causing a log warning and returning an empty string. There is no evidence in the commit of a security vulnerability being fixed; it reads as a compatibility/usability fix.
Changed components
electrum/interface.pyInterface._get_donation_address()Inspect captured patch +6 / −3
diff --git a/electrum/interface.py b/electrum/interface.py
index b9827cf..196d13c 100644
--- a/electrum/interface.py
+++ b/electrum/interface.py
@@ -1560,12 +1560,15 @@ class Interface(Logger):
# check response
if not res: # ignore empty string
return ''
- if not bitcoin.is_address(res):
+ if not isinstance(res, str):
+ raise RequestCorrupted(f'{res!r} should be a str')
+ address = res.removeprefix('bitcoin:')
+ if not bitcoin.is_address(address):
# note: do not hard-fail -- allow server to use future-type
# bitcoin address we do not recognize
self.logger.info(f"invalid donation address from server: {repr(res)}")
- res = ''
- return res
+ return ''
+ return address
async def get_relay_fee(self) -> int:
"""Returns the min relay feerate in sat/kbyte."""
Why this scored 21/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.