Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_txoutproof.py
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
tx1 = self.nodes[0].createrawtransaction( | tx1 = self.nodes[0].createrawtransaction( | ||||
[node0utxos.pop()], {self.nodes[1].getnewaddress(): 49.99}) | [node0utxos.pop()], {self.nodes[1].getnewaddress(): 49.99}) | ||||
txid1 = self.nodes[0].sendrawtransaction( | txid1 = self.nodes[0].sendrawtransaction( | ||||
self.nodes[0].signrawtransactionwithwallet(tx1)["hex"]) | self.nodes[0].signrawtransactionwithwallet(tx1)["hex"]) | ||||
tx2 = self.nodes[0].createrawtransaction( | tx2 = self.nodes[0].createrawtransaction( | ||||
[node0utxos.pop()], {self.nodes[1].getnewaddress(): 49.99}) | [node0utxos.pop()], {self.nodes[1].getnewaddress(): 49.99}) | ||||
txid2 = self.nodes[0].sendrawtransaction( | txid2 = self.nodes[0].sendrawtransaction( | ||||
self.nodes[0].signrawtransactionwithwallet(tx2)["hex"]) | self.nodes[0].signrawtransactionwithwallet(tx2)["hex"]) | ||||
# This will raise an exception because the transaction is not yet in a block | # This will raise an exception because the transaction is not yet in a | ||||
# block | |||||
assert_raises_rpc_error(-5, "Transaction not yet in block", | assert_raises_rpc_error(-5, "Transaction not yet in block", | ||||
self.nodes[0].gettxoutproof, [txid1]) | self.nodes[0].gettxoutproof, [txid1]) | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
blockhash = self.nodes[0].getblockhash(chain_height + 1) | blockhash = self.nodes[0].getblockhash(chain_height + 1) | ||||
self.sync_all() | self.sync_all() | ||||
txlist = [] | txlist = [] | ||||
Show All 26 Lines | def run_test(self): | ||||
assert_equal(self.nodes[2].verifytxoutproof( | assert_equal(self.nodes[2].verifytxoutproof( | ||||
self.nodes[2].gettxoutproof([txid_spent], blockhash)), [txid_spent]) | self.nodes[2].gettxoutproof([txid_spent], blockhash)), [txid_spent]) | ||||
# We can't get the proof if we specify a non-existent block | # We can't get the proof if we specify a non-existent block | ||||
assert_raises_rpc_error(-5, "Block not found", self.nodes[2].gettxoutproof, [ | assert_raises_rpc_error(-5, "Block not found", self.nodes[2].gettxoutproof, [ | ||||
txid_spent], "00000000000000000000000000000000") | txid_spent], "00000000000000000000000000000000") | ||||
# We can get the proof if the transaction is unspent | # We can get the proof if the transaction is unspent | ||||
assert_equal(self.nodes[2].verifytxoutproof( | assert_equal(self.nodes[2].verifytxoutproof( | ||||
self.nodes[2].gettxoutproof([txid_unspent])), [txid_unspent]) | self.nodes[2].gettxoutproof([txid_unspent])), [txid_unspent]) | ||||
# We can get the proof if we provide a list of transactions and one of them is unspent. The ordering of the list should not matter. | # We can get the proof if we provide a list of transactions and one of | ||||
# them is unspent. The ordering of the list should not matter. | |||||
assert_equal(sorted(self.nodes[2].verifytxoutproof( | assert_equal(sorted(self.nodes[2].verifytxoutproof( | ||||
self.nodes[2].gettxoutproof([txid1, txid2]))), sorted(txlist)) | self.nodes[2].gettxoutproof([txid1, txid2]))), sorted(txlist)) | ||||
assert_equal(sorted(self.nodes[2].verifytxoutproof( | assert_equal(sorted(self.nodes[2].verifytxoutproof( | ||||
self.nodes[2].gettxoutproof([txid2, txid1]))), sorted(txlist)) | self.nodes[2].gettxoutproof([txid2, txid1]))), sorted(txlist)) | ||||
# We can always get a proof if we have a -txindex | # We can always get a proof if we have a -txindex | ||||
assert_equal(self.nodes[2].verifytxoutproof( | assert_equal(self.nodes[2].verifytxoutproof( | ||||
self.nodes[3].gettxoutproof([txid_spent])), [txid_spent]) | self.nodes[3].gettxoutproof([txid_spent])), [txid_spent]) | ||||
# We can't get a proof if we specify transactions from different blocks | # We can't get a proof if we specify transactions from different blocks | ||||
Show All 28 Lines |