Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_fundrawtransaction.py
Show First 20 Lines • Show All 454 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.sync_all() | self.sync_all() | ||||
oldBalance = self.nodes[1].getbalance() | oldBalance = self.nodes[1].getbalance() | ||||
inputs = [] | inputs = [] | ||||
outputs = {self.nodes[1].getnewaddress(): 1.1} | outputs = {self.nodes[1].getnewaddress(): 1.1} | ||||
rawTx = self.nodes[2].createrawtransaction(inputs, outputs) | rawTx = self.nodes[2].createrawtransaction(inputs, outputs) | ||||
fundedTx = self.nodes[2].fundrawtransaction(rawTx) | fundedTx = self.nodes[2].fundrawtransaction(rawTx) | ||||
signedTx = self.nodes[2].signrawtransaction(fundedTx['hex']) | signedTx = self.nodes[2].signrawtransactionwithwallet(fundedTx['hex']) | ||||
txId = self.nodes[2].sendrawtransaction(signedTx['hex']) | txId = self.nodes[2].sendrawtransaction(signedTx['hex']) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[1].generate(1) | self.nodes[1].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
# make sure funds are received at node1 | # make sure funds are received at node1 | ||||
assert_equal( | assert_equal( | ||||
oldBalance + Decimal('1.10000000'), self.nodes[1].getbalance()) | oldBalance + Decimal('1.10000000'), self.nodes[1].getbalance()) | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
inputs = [] | inputs = [] | ||||
outputs = {self.nodes[0].getnewaddress(): 1.1} | outputs = {self.nodes[0].getnewaddress(): 1.1} | ||||
rawTx = self.nodes[1].createrawtransaction(inputs, outputs) | rawTx = self.nodes[1].createrawtransaction(inputs, outputs) | ||||
fundedTx = self.nodes[1].fundrawtransaction(rawTx) | fundedTx = self.nodes[1].fundrawtransaction(rawTx) | ||||
# now we need to unlock | # now we need to unlock | ||||
self.nodes[1].walletpassphrase("test", 600) | self.nodes[1].walletpassphrase("test", 600) | ||||
signedTx = self.nodes[1].signrawtransaction(fundedTx['hex']) | signedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex']) | ||||
txId = self.nodes[1].sendrawtransaction(signedTx['hex']) | txId = self.nodes[1].sendrawtransaction(signedTx['hex']) | ||||
self.nodes[1].generate(1) | self.nodes[1].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
# make sure funds are received at node1 | # make sure funds are received at node1 | ||||
assert_equal( | assert_equal( | ||||
oldBalance + Decimal('51.10000000'), self.nodes[0].getbalance()) | oldBalance + Decimal('51.10000000'), self.nodes[0].getbalance()) | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# fund a tx with ~20 small inputs | # fund a tx with ~20 small inputs | ||||
oldBalance = self.nodes[0].getbalance() | oldBalance = self.nodes[0].getbalance() | ||||
inputs = [] | inputs = [] | ||||
outputs = { | outputs = { | ||||
self.nodes[0].getnewaddress(): 0.15, self.nodes[0].getnewaddress(): 0.04} | self.nodes[0].getnewaddress(): 0.15, self.nodes[0].getnewaddress(): 0.04} | ||||
rawTx = self.nodes[1].createrawtransaction(inputs, outputs) | rawTx = self.nodes[1].createrawtransaction(inputs, outputs) | ||||
fundedTx = self.nodes[1].fundrawtransaction(rawTx) | fundedTx = self.nodes[1].fundrawtransaction(rawTx) | ||||
fundedAndSignedTx = self.nodes[1].signrawtransaction(fundedTx['hex']) | fundedAndSignedTx = self.nodes[1].signrawtransactionwithwallet( | ||||
fundedTx['hex']) | |||||
txId = self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex']) | txId = self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex']) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
assert_equal(oldBalance + Decimal('50.19000000'), | assert_equal(oldBalance + Decimal('50.19000000'), | ||||
self.nodes[0].getbalance()) # 0.19+block reward | self.nodes[0].getbalance()) # 0.19+block reward | ||||
# | # | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert(res_dec["vin"][0]["txid"] == watchonly_txid or res_dec[ | assert(res_dec["vin"][0]["txid"] == watchonly_txid or res_dec[ | ||||
"vin"][1]["txid"] == watchonly_txid) | "vin"][1]["txid"] == watchonly_txid) | ||||
assert_greater_than(result["fee"], 0) | assert_greater_than(result["fee"], 0) | ||||
assert_greater_than(result["changepos"], -1) | assert_greater_than(result["changepos"], -1) | ||||
assert_equal(result["fee"] + res_dec["vout"][ | assert_equal(result["fee"] + res_dec["vout"][ | ||||
result["changepos"]]["value"], watchonly_amount / 10) | result["changepos"]]["value"], watchonly_amount / 10) | ||||
signedtx = self.nodes[3].signrawtransaction(result["hex"]) | signedtx = self.nodes[3].signrawtransactionwithwallet(result["hex"]) | ||||
assert(not signedtx["complete"]) | assert(not signedtx["complete"]) | ||||
signedtx = self.nodes[0].signrawtransaction(signedtx["hex"]) | signedtx = self.nodes[0].signrawtransactionwithwallet(signedtx["hex"]) | ||||
assert(signedtx["complete"]) | assert(signedtx["complete"]) | ||||
self.nodes[0].sendrawtransaction(signedtx["hex"]) | self.nodes[0].sendrawtransaction(signedtx["hex"]) | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
# | # | ||||
# Test feeRate option # | # Test feeRate option # | ||||
# | # | ||||
▲ Show 20 Lines • Show All 135 Lines • Show Last 20 Lines |