Exemplo n.º 1
0
print(r.text)
# being this a demontrational code no file or directies will be created.
# I print everything for future transactions. Feel free to change the code
# for key storing inside gpg protected files etc.
print("")
print("Gererated public wallet : %s" % mpk3) # created and supplied by Cryptocorp
print("BIP32 wallet n.1        : %s" % hwif1.hwif(as_private=True))
print("BIP32 wallet n.2        : %s" % hwif2.hwif(as_private=True))
print("")

#path: 0/0/7 easy to remember

path = "0/0/7"


spk1 = BIP32Node.subkey_for_path(hwif1, path)
spk2 = BIP32Node.subkey_for_path(hwif2, path)
spk3 = BIP32Node.subkey_for_path(hmpk1, path)

#list of the public keys in sec format (to display them)
print("public keys in hex:")
print (BIP32Node.subkey_for_path(hwif1, path).sec_as_hex())
print (BIP32Node.subkey_for_path(hwif2, path).sec_as_hex())
print (BIP32Node.subkey_for_path(hmpk1, path).sec_as_hex())

#public subkeys in sec binary format (because ScriptMultisig requires it)
keys = [spk1, spk2, spk3] #just remember that the third has not the secret exponent
print(keys)
script = ScriptMultisig(n=2, sec_keys=[key.sec() for key in keys]).script()
print("script:")
print(b2h(script))
Exemplo n.º 2
0
<<<<<<< Updated upstream

# Also cryptocorp's key is supplyed
=======
private_wallets = json.load(open((chain_file + ".mseks.json"), "r"))
# The next is because I will use only one key
private_wallets.remove(private_wallets[1])
>>>>>>> Stashed changes
chainPaths = ["0/0/7","0/0/7","0/0/7"]
print("Chain paths:")
pp.pprint(chainPaths)
print("")

# masterbip32nodes = [Key.from_text(i) for i in public_wallets]

sub_bip32_nodes = [BIP32Node.subkey_for_path(Key.from_text(public_wallets[i]), chainPaths[i]) for i in range(len(chainPaths))]
print("Sub BIP32 wallets:")
for i in sub_bip32_nodes:
    print(i)

print("")

script_encoded = ScriptMultisig(n=2, sec_keys=[key.sec() for key in sub_bip32_nodes]).script()

script = b2h(script_encoded)
print("Script:")
print(script)
print("")

address = address_for_pay_to_script(script_encoded)
# 3Bi36w9RZHmibi1ip7ud9dvtpDt59ij7GC