BIP-0350: use bech32m for witness version 1+ addresses
We have supported sending to any witness version since Electrum 3.0, using
addresses as specified in BIP-0173 (bech32 encoding).
BIP-0350 makes a breaking change in address encoding, and recommends using
(and using only) a new encoding (bech32m) for sending to witness version 1
and later. The address encoding for currently in use witness v0 addresses
remains the same, as in BIP-0173; following the BIP-0350 spec.
closes https://github.com/spesmilo/electrum/issues/6949
related:
cd3885c0fb/bip-0350.mediawiki
https://github.com/bitcoin/bitcoin/pull/20861
This commit is contained in:
@@ -1165,7 +1165,13 @@ class LNPeerAddr:
|
||||
|
||||
|
||||
def get_compressed_pubkey_from_bech32(bech32_pubkey: str) -> bytes:
|
||||
hrp, data_5bits = segwit_addr.bech32_decode(bech32_pubkey)
|
||||
decoded_bech32 = segwit_addr.bech32_decode(bech32_pubkey)
|
||||
hrp = decoded_bech32.hrp
|
||||
data_5bits = decoded_bech32.data
|
||||
if decoded_bech32.encoding is None:
|
||||
raise ValueError("Bad bech32 checksum")
|
||||
if decoded_bech32.encoding != segwit_addr.Encoding.BECH32:
|
||||
raise ValueError("Bad bech32 encoding: must be using vanilla BECH32")
|
||||
if hrp != 'ln':
|
||||
raise Exception('unexpected hrp: {}'.format(hrp))
|
||||
data_8bits = segwit_addr.convertbits(data_5bits, 5, 8, False)
|
||||
|
||||
Reference in New Issue
Block a user