def signpsbt_handler(args): multisig = MultiSig.open(args.filename) client, device = get_client_and_device(args, multisig) psbt = multisig.psbt raw_signed_psbt = client.sign_tx(multisig.psbt)['psbt'] new_psbt = serializations.PSBT() new_psbt.deserialize(raw_signed_psbt) multisig.psbt = new_psbt multisig.save()
def createpsbt_handler(args): multisig = MultiSig.open(args.filename) if multisig.psbt: user_input = input( "You already have a PSBT. Would you like to erase it and start a new one? (y/n)" ) if user_input == 'y': multisig.remove_psbt() else: print("Cancelled") return multisig.create_psbt(args.recipient, args.amount) print(f"Your PSBT for wallet \"{multisig.name}\" has been created") print("View it with \"python cli.py decodepsbt\"")
def addsigner_handler(args): multisig = MultiSig.open(args.filename) client, device = get_client_and_device(args, multisig) # Create and add a "signer" to the wallet master_xpub = client.get_pubkey_at_path('m/0h')['xpub'] origin_path = "m/44h/1h/0h" base_key = client.get_pubkey_at_path(origin_path)['xpub'] multisig.add_signer(args.name, device['fingerprint'], base_key, origin_path) print( f"Signer \"{args.name}\" has been added to your \"{multisig.name}\" wallet" ) # Print messages depending on whether the setup is complete or not if multisig.ready(): print( f"Wallet \"{multisig.name}\" is ready to use. Your first receiving address:" ) print(multisig.address()) else: signers_missing = multisig.n - len(multisig.signers) print(f"Add {signers_missing} more signers to start using it")
def listwallets_handler(args): for filename in glob.glob("*.json"): multisig = MultiSig.open(filename) display_wallet(multisig) print()
def describewallet_handler(args): multisig = MultiSig.open(args.filename) display_wallet(multisig)
def broadcast_handler(args): multisig = MultiSig.open(args.filename) txid = multisig.broadcast() print("Transaction ID:", txid)
def decodepsbt_handler(args): multisig = MultiSig.open(args.filename) pprint(multisig.decode_psbt())
def createwallet_handler(args): multisig = MultiSig.create(args.name, args.m, args.n) print( f"Your new {multisig.m}/{multisig.n} wallet has been saved to \"{multisig.filename()}\"" )
def address_handler(args): multisig = MultiSig.open(args.filename) print(multisig.address())