electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit b83f7159a9dd635a7a6f12d479e8704f6d7ae4b2
parent d7597d96d0c336838adb32e3e175d3ea6f9763e8
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun, 28 Feb 2021 16:53:21 +0100

bech32: around 5% speedup for bech32_decode

useful for lnaddr.lndecode

Diffstat:
Melectrum/segwit_addr.py | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/electrum/segwit_addr.py b/electrum/segwit_addr.py @@ -23,6 +23,7 @@ CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l" +_CHARSET_INVERSE = {x: CHARSET.find(x) for x in CHARSET} def bech32_polymod(values): @@ -72,7 +73,7 @@ def bech32_decode(bech, ignore_long_length=False): if not all(x in CHARSET for x in bech[pos+1:]): return (None, None) hrp = bech[:pos] - data = [CHARSET.find(x) for x in bech[pos+1:]] + data = [_CHARSET_INVERSE[x] for x in bech[pos+1:]] if not bech32_verify_checksum(hrp, data): return (None, None) return (hrp, data[:-6])