"@127.0.0.1:" + str(sidechain_port)) sidechain2 = AuthServiceProxy("http://*****:*****@127.0.0.1:" + str(sidechain2_port)) print("Daemons started, making blocks to get funds") bitcoin.generate(101) sidechain.generate(101) addr = bitcoin.getnewaddress() # Lockup some funds to unlock later sidechain.sendtomainchain(addr, 50) sidechain.generate(101) addrs = sidechain.getpeginaddress() txid = bitcoin.sendtoaddress(addrs["mainchain_address"], 49) bitcoin.generate(10) proof = bitcoin.gettxoutproof([txid]) raw = bitcoin.getrawtransaction(txid) print("Attempting peg-in") # Should fail due to non-matching address try: pegtxid = sidechain.claimpegin(raw, proof, sidechain.getnewaddress()) raise Exception("Peg-in with non-matching address should fail.") except JSONRPCException: pass timeout = 20 # Should succeed via wallet lookup for address match
bitcoin = AuthServiceProxy("http://*****:*****@127.0.0.1:" + str(bitcoin_port)) sidechain = AuthServiceProxy("http://*****:*****@127.0.0.1:" + str(sidechain_port)) sidechain2 = AuthServiceProxy("http://*****:*****@127.0.0.1:" + str(sidechain2_port)) print("Daemons started, making blocks to get funds") bitcoin.generate(101) sidechain.generate(101) addr = bitcoin.getnewaddress() addrs = sidechain.getpeginaddress() txid1 = bitcoin.sendtoaddress(addrs["mainchain_address"], 24) # 10+2 confirms required to get into mempool and confirm bitcoin.generate(11) time.sleep(2) proof = bitcoin.gettxoutproof([txid1]) raw = bitcoin.getrawtransaction(txid1) print("Attempting peg-in") try: pegtxid = sidechain.claimpegin(raw, proof) raise Exception( "Peg-in should not mature enough yet, need another block.") except JSONRPCException as e: assert ( "Peg-in Bitcoin transaction needs more confirmations to be sent." in e.error["message"])
print("Daemons started, making blocks to get funds") bitcoin.generate(101) sidechain.generate(101) addr = bitcoin.getnewaddress() # First, blackhole all 21M bitcoin that already exist(and test subtractfrom) assert(sidechain.getwalletinfo()["balance"]["bitcoin"] == 21000000) sidechain.sendtomainchain(addr, 21000000, True) assert("bitcoin" not in sidechain.getwalletinfo()["balance"]) sidechain.generate(101) addrs = sidechain.getpeginaddress() txid1 = bitcoin.sendtoaddress(addrs["mainchain_address"], 24) # 10+2 confirms required to get into mempool and confirm bitcoin.generate(1) time.sleep(2) proof = bitcoin.gettxoutproof([txid1]) raw = bitcoin.getrawtransaction(txid1) print("Attempting peg-in") # First attempt fails the consensus check but gives useful result try: pegtxid = sidechain.claimpegin(raw, proof) raise Exception("Peg-in should not be mature enough yet, need another block.") except JSONRPCException as e: assert("Peg-in Bitcoin transaction needs more confirmations to be sent." in e.error["message"]) pass