Skip to content

Instantly share code, notes, and snippets.

@JimmyMow
Created January 30, 2016 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JimmyMow/525e9e3a1bb438b10b4b to your computer and use it in GitHub Desktop.
Save JimmyMow/525e9e3a1bb438b10b4b to your computer and use it in GitHub Desktop.
TypeError: Script does not start with OP_0!
from two1.lib.wallet import Wallet, exceptions
from two1.lib.bitcoin.crypto import PublicKey
from two1.lib.bitcoin.script import Script
from two1.lib.bitcoin.txn import Transaction
SRV_ACCT = 'signing'
wallet = Wallet()
try:
print("attempting to create account 'signing'")
wallet.create_account(SRV_ACCT)
except exceptions.AccountCreationError:
print("already have account signing created")
pass
next_idx = 1
print(next_idx)
server_hd_pubkey = wallet.get_message_signing_public_key(SRV_ACCT, next_idx)
server_pubkey = server_hd_pubkey.compressed_bytes
owner_pubkey = PublicKey.from_bytes("040D3711FB353EDF77A13D1A3A33CFC7E04EEE626C9738EECC23754C06083DB8058C4F6DDFFE3445C1ADD3B1D121F70FE3B56EADD260AD43ED517C25B10FFBC3D0").compressed_bytes
other_pubkey = PublicKey.from_bytes("045AC8DD1042E3C7210324720F2520ED5B42CDBDC31610E3936E4925C67D37CDB3A0E1661B8BDAC2A090BD3425CDA715DFE131E591A27E7DF6A5CCC66383AE8E16").compressed_bytes
print(server_pubkey)
print(owner_pubkey)
print(other_pubkey)
multi_script = Script.build_multisig_redeem(2, [owner_pubkey, server_pubkey, other_pubkey])
address = multi_script.address()
reedem_info = multi_script.extract_multisig_redeem_info()
print(multi_script)
print(address)
print(reedem_info)
pbkey = wallet.get_payout_public_key(SRV_ACCT)
print(pbkey)
prkey = wallet.get_private_for_public(pbkey)
print(prkey)
tx = wallet.send_to(address, 5000)
txid = tx[0]['txid']
tx_object = tx[0]['txn']
input_idx = 0
print(tx)
print(txid)
print("tx inputs:")
print(type(tx_object.inputs))
print("----------------------------------------")
print(tx_object)
print(input_idx)
print(Transaction.SIG_HASH_ALL)
print(prkey)
print(multi_script)
print("----------------------------------------")
idx = 0
print("k im here")
for ip in tx_object.inputs:
print("woah its cool in here lol")
signed = tx_object.sign_input(idx, Transaction.SIG_HASH_ALL, prkey, multi_script)
print("something happened! never been here!")
if not signed:
print("Trouble signing input %d." % idx)
abort(400)
idx += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment