Created
April 27, 2018 08:34
-
-
Save badmofo/87fdfb9b864507bde3483d251c243ac2 to your computer and use it in GitHub Desktop.
convert bitcoin addr to bitcoin private addr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bitcoin | |
def btc_to_btcp(addr): | |
assert addr[0] in ('1', '3') # we don't support bech32 addrs for now | |
addr_prefix = b'\x13\x25' if addr[0] == '1' else b'\x13\xaf' | |
pkh = bitcoin.b58check_to_bin(addr) | |
assert len(pkh) == 20 | |
return bitcoin.bin_to_b58check(addr_prefix[1:2] + pkh, addr_prefix[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment