Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/address.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2016-2019 The Bitcoin Core developers | # Copyright (c) 2016-2019 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Encode and decode BASE58, P2PKH and P2SH addresses.""" | """Encode and decode BASE58, P2PKH and P2SH addresses.""" | ||||
import unittest | import unittest | ||||
from .script import CScript, hash160, hash256 | from .script import CScript, hash160, hash256 | ||||
from .util import assert_equal, hex_str_to_bytes | from .util import assert_equal, hex_str_to_bytes | ||||
ADDRESS_ECREG_UNSPENDABLE = 'ecregtest:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqcrl5mqkt' | ADDRESS_ECREG_UNSPENDABLE = 'ecregtest:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqcrl5mqkt' | ||||
ADDRESS_ECREG_UNSPENDABLE_DESCRIPTOR = 'addr(ecregtest:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqcrl5mqkt)#u6xx93xc' | ADDRESS_ECREG_UNSPENDABLE_DESCRIPTOR = 'addr(ecregtest:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqcrl5mqkt)#u6xx93xc' | ||||
# Coins sent to this address can be spent with a scriptSig of just OP_TRUE | |||||
ADDRESS_P2SH_OP_TRUE = 'ecregtest:prdpw30fk4ym6zl6rftfjuw806arpn26fvkgfu97xt' | |||||
chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' | chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' | ||||
def byte_to_base58(b, version): | def byte_to_base58(b, version): | ||||
result = '' | result = '' | ||||
str = b.hex() | str = b.hex() | ||||
str = chr(version).encode('latin-1').hex() + str | str = chr(version).encode('latin-1').hex() + str | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |