mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-09-27 23:37:32 +02:00
scripted-diff: rename chars
to b58chars
in test_framework.address
-BEGIN VERIFY SCRIPT- sed -i 's/chars/b58chars/g' ./test/functional/test_framework/address.py -END VERIFY SCRIPT-
This commit is contained in:
@@ -35,7 +35,7 @@ class AddressType(enum.Enum):
|
|||||||
legacy = 'legacy' # P2PKH
|
legacy = 'legacy' # P2PKH
|
||||||
|
|
||||||
|
|
||||||
chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
||||||
|
|
||||||
|
|
||||||
def create_deterministic_address_bcrt1_p2tr_op_true():
|
def create_deterministic_address_bcrt1_p2tr_op_true():
|
||||||
@@ -59,10 +59,10 @@ def byte_to_base58(b, version):
|
|||||||
b += hash256(b)[:4] # append checksum
|
b += hash256(b)[:4] # append checksum
|
||||||
value = int.from_bytes(b, 'big')
|
value = int.from_bytes(b, 'big')
|
||||||
while value > 0:
|
while value > 0:
|
||||||
result = chars[value % 58] + result
|
result = b58chars[value % 58] + result
|
||||||
value //= 58
|
value //= 58
|
||||||
while b[0] == 0:
|
while b[0] == 0:
|
||||||
result = chars[0] + result
|
result = b58chars[0] + result
|
||||||
b = b[1:]
|
b = b[1:]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -76,8 +76,8 @@ def base58_to_byte(s):
|
|||||||
n = 0
|
n = 0
|
||||||
for c in s:
|
for c in s:
|
||||||
n *= 58
|
n *= 58
|
||||||
assert c in chars
|
assert c in b58chars
|
||||||
digit = chars.index(c)
|
digit = b58chars.index(c)
|
||||||
n += digit
|
n += digit
|
||||||
h = '%x' % n
|
h = '%x' % n
|
||||||
if len(h) % 2:
|
if len(h) % 2:
|
||||||
@@ -85,7 +85,7 @@ def base58_to_byte(s):
|
|||||||
res = n.to_bytes((n.bit_length() + 7) // 8, 'big')
|
res = n.to_bytes((n.bit_length() + 7) // 8, 'big')
|
||||||
pad = 0
|
pad = 0
|
||||||
for c in s:
|
for c in s:
|
||||||
if c == chars[0]:
|
if c == b58chars[0]:
|
||||||
pad += 1
|
pad += 1
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
Reference in New Issue
Block a user