Last active
September 13, 2016 04:59
-
-
Save coblee/9c890963164379116f5f3d42f03d0275 to your computer and use it in GitHub Desktop.
Bitcoin -> Litecoin address conversions using https://github.com/vbuterin/pybitcointools
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
from bitcoin import * | |
# private key conversion | |
privkey = "L2Gkw3kKJ6N24QcDuH4XDqt9cTqsKTVNDGz1CRZhk9cq4auDUbJy" | |
encode_privkey(privkey, get_privkey_format(privkey), 48) | |
# testnet | |
encode_privkey(privkey, get_privkey_format(privkey), 111) | |
# public key conversion | |
pubkey = "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i" | |
bin_to_b58check(b58check_to_bin(pubkey), 48) | |
# bip32 conversions | |
MAINNET_PRIVATE = b'\x01\x9D\x9C\xFE' | |
MAINNET_PUBLIC = b'\x01\x9D\xA4\x62' | |
TESTNET_PRIVATE = b'\x04\x36\xEF\x7D' | |
TESTNET_PUBLIC = b'\x04\x36\xF6\xE1' | |
data = "tpubD6NzVbkrYhZ4WZaiWHz59q5EQ61bd6dUYfU4ggRWAtNAyyYRNWT6ktJ7UHJEXURvTfTfskFQmK7Ff4FRkiRN5wQH8nkGAb6aKB4Yyeqsw5m" | |
dbin = changebase(data, 58, 256) | |
if from_byte_to_int(dbin[3]) == 228: | |
bindata = MAINNET_PRIVATE + dbin[4:-4] | |
elif from_byte_to_int(dbin[3]) == 30: | |
bindata = MAINNET_PUBLIC + dbin[4:-4] | |
elif from_byte_to_int(dbin[3]) == 148: | |
bindata = TESTNET_PRIVATE + dbin[4:-4] | |
else: | |
bindata = TESTNET_PUBLIC + dbin[4:-4] | |
changebase(bindata+bin_dbl_sha256(bindata)[:4], 256, 58) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment