Add support for palladium BIP21 URI scheme

The changes introduce a new URI scheme 'palladium' alongside the existing 'bitcoin' scheme for BIP21 payment URIs. This allows the wallet to parse and handle palladium payment URIs in the same way as bitcoin URIs.
This commit is contained in:
2025-11-21 10:45:05 +01:00
parent 9fdd0ac4f5
commit 35f9ac77f6
2 changed files with 6 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ from .lnaddr import lndecode, LnDecodeException
# note: when checking against these, use .lower() to support case-insensitivity
BITCOIN_BIP21_URI_SCHEME = 'bitcoin'
PALLADIUM_BIP21_URI_SCHEME = 'palladium'
LIGHTNING_URI_SCHEME = 'lightning'
@@ -29,8 +30,8 @@ def parse_bip21_URI(uri: str) -> dict:
return {'address': uri}
u = urllib.parse.urlparse(uri)
if u.scheme.lower() != BITCOIN_BIP21_URI_SCHEME:
raise InvalidBitcoinURI("Not a bitcoin URI")
if u.scheme.lower() != PALLADIUM_BIP21_URI_SCHEME:
raise InvalidBitcoinURI("Not a palladium URI")
address = u.path
# python for android fails to parse query
@@ -120,7 +121,7 @@ def create_bip21_uri(addr, amount_sat: Optional[int], message: Optional[str],
v = urllib.parse.quote(v)
query.append(f"{k}={v}")
p = urllib.parse.ParseResult(
scheme=BITCOIN_BIP21_URI_SCHEME,
scheme=PALLADIUM_BIP21_URI_SCHEME,
netloc='',
path=addr,
params='',

View File

@@ -20,7 +20,7 @@ from .lnurl import (decode_lnurl, request_lnurl, callback_lnurl, LNURLError,
from .bitcoin import opcodes, construct_script
from .lnaddr import LnInvoiceException
from .lnutil import IncompatibleOrInsaneFeatures
from .bip21 import parse_bip21_URI, InvalidBitcoinURI, LIGHTNING_URI_SCHEME, BITCOIN_BIP21_URI_SCHEME
from .bip21 import parse_bip21_URI, InvalidBitcoinURI, LIGHTNING_URI_SCHEME, BITCOIN_BIP21_URI_SCHEME, PALLADIUM_BIP21_URI_SCHEME
from . import paymentrequest
if TYPE_CHECKING:
@@ -245,7 +245,7 @@ class PaymentIdentifier(Logger):
self.logger.debug(f'Exception cause {e.args!r}')
return
self.set_state(PaymentIdentifierState.AVAILABLE)
elif text.lower().startswith(BITCOIN_BIP21_URI_SCHEME + ':'):
elif text.lower().startswith(BITCOIN_BIP21_URI_SCHEME + ':') or text.lower().startswith(PALLADIUM_BIP21_URI_SCHEME + ':'):
try:
out = parse_bip21_URI(text)
except InvalidBitcoinURI as e: