Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_fundrawtransaction.py
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.test_many_inputs_fee() | self.test_many_inputs_fee() | ||||
self.test_many_inputs_send() | self.test_many_inputs_send() | ||||
self.test_op_return() | self.test_op_return() | ||||
self.test_watchonly() | self.test_watchonly() | ||||
self.test_all_watched_funds() | self.test_all_watched_funds() | ||||
self.test_option_feerate() | self.test_option_feerate() | ||||
self.test_address_reuse() | self.test_address_reuse() | ||||
self.test_option_subtract_fee_from_outputs() | self.test_option_subtract_fee_from_outputs() | ||||
self.test_subtract_fee_with_presets() | |||||
def test_change_position(self): | def test_change_position(self): | ||||
# ensure that setting changePosition in fundraw with an exact match is | # ensure that setting changePosition in fundraw with an exact match is | ||||
# handled properly | # handled properly | ||||
rawmatch = self.nodes[2].createrawtransaction( | rawmatch = self.nodes[2].createrawtransaction( | ||||
[], {self.nodes[2].getnewaddress(): 50}) | [], {self.nodes[2].getnewaddress(): 50}) | ||||
rawmatch = self.nodes[2].fundrawtransaction( | rawmatch = self.nodes[2].fundrawtransaction( | ||||
rawmatch, {"changePosition": 1, "subtractFeeFromOutputs": [0]}) | rawmatch, {"changePosition": 1, "subtractFeeFromOutputs": [0]}) | ||||
▲ Show 20 Lines • Show All 742 Lines • ▼ Show 20 Lines | def test_option_subtract_fee_from_outputs(self): | ||||
assert_greater_than_or_equal(share[2] + Decimal(2e-8), share[0]) | assert_greater_than_or_equal(share[2] + Decimal(2e-8), share[0]) | ||||
# the fee is the same in both transactions | # the fee is the same in both transactions | ||||
assert_equal(result[0]['fee'], result[1]['fee']) | assert_equal(result[0]['fee'], result[1]['fee']) | ||||
# the total subtracted from the outputs is equal to the fee | # the total subtracted from the outputs is equal to the fee | ||||
assert_equal(share[0] + share[2] + share[3], result[0]['fee']) | assert_equal(share[0] + share[2] + share[3], result[0]['fee']) | ||||
def test_subtract_fee_with_presets(self): | |||||
self.log.info( | |||||
"Test fundrawtxn subtract fee from outputs with preset inputs that are sufficient") | |||||
addr = self.nodes[0].getnewaddress() | |||||
txid = self.nodes[0].sendtoaddress(addr, 10) | |||||
vout = find_vout_for_address(self.nodes[0], txid, addr) | |||||
rawtx = self.nodes[0].createrawtransaction([{'txid': txid, 'vout': vout}], [ | |||||
{self.nodes[0].getnewaddress(): 5}]) | |||||
fundedtx = self.nodes[0].fundrawtransaction( | |||||
rawtx, {'subtractFeeFromOutputs': [0]}) | |||||
signedtx = self.nodes[0].signrawtransactionwithwallet(fundedtx['hex']) | |||||
self.nodes[0].sendrawtransaction(signedtx['hex']) | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
RawTransactionsTest().main() | RawTransactionsTest().main() |