Changeset View
Changeset View
Standalone View
Standalone View
test/functional/fundrawtransaction.py
Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# | # | ||||
# test a fundrawtransaction with which will not get a change output # | # test a fundrawtransaction with which will not get a change output # | ||||
# | # | ||||
utx = get_unspent(self.nodes[2].listunspent(), 5) | utx = get_unspent(self.nodes[2].listunspent(), 5) | ||||
inputs = [{'txid': utx['txid'], 'vout': utx['vout']}] | inputs = [{'txid': utx['txid'], 'vout': utx['vout']}] | ||||
outputs = { | outputs = { | ||||
self.nodes[0].getnewaddress(): Decimal(5.0) - fee - feeTolerance} | self.nodes[0].getnewaddress(): satoshi_round(Decimal(5.0) - fee - feeTolerance)} | ||||
rawtx = self.nodes[2].createrawtransaction(inputs, outputs) | rawtx = self.nodes[2].createrawtransaction(inputs, outputs) | ||||
dec_tx = self.nodes[2].decoderawtransaction(rawtx) | dec_tx = self.nodes[2].decoderawtransaction(rawtx) | ||||
assert_equal(utx['txid'], dec_tx['vin'][0]['txid']) | assert_equal(utx['txid'], dec_tx['vin'][0]['txid']) | ||||
rawtxfund = self.nodes[2].fundrawtransaction(rawtx) | rawtxfund = self.nodes[2].fundrawtransaction(rawtx) | ||||
fee = rawtxfund['fee'] | fee = rawtxfund['fee'] | ||||
dec_tx = self.nodes[2].decoderawtransaction(rawtxfund['hex']) | dec_tx = self.nodes[2].decoderawtransaction(rawtxfund['hex']) | ||||
totalOut = 0 | totalOut = 0 | ||||
▲ Show 20 Lines • Show All 482 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
inputs = [] | inputs = [] | ||||
outputs = {self.nodes[3].getnewaddress(): 1} | outputs = {self.nodes[3].getnewaddress(): 1} | ||||
rawtx = self.nodes[3].createrawtransaction(inputs, outputs) | rawtx = self.nodes[3].createrawtransaction(inputs, outputs) | ||||
result = self.nodes[3].fundrawtransaction( | result = self.nodes[3].fundrawtransaction( | ||||
rawtx) # uses min_relay_tx_fee (set by settxfee) | rawtx) # uses min_relay_tx_fee (set by settxfee) | ||||
result2 = self.nodes[3].fundrawtransaction( | result2 = self.nodes[3].fundrawtransaction( | ||||
rawtx, {"feeRate": 2 * min_relay_tx_fee}) | rawtx, {"feeRate": 2 * min_relay_tx_fee}) | ||||
assert_fee_amount( | |||||
result2['fee'], FromHex(CTransaction(), result2['hex']).billable_size(), 2 * min_relay_tx_fee) | |||||
result3 = self.nodes[3].fundrawtransaction( | result3 = self.nodes[3].fundrawtransaction( | ||||
rawtx, {"feeRate": 10 * min_relay_tx_fee}) | rawtx, {"feeRate": 10 * min_relay_tx_fee}) | ||||
result_fee_rate = result['fee'] * 1000 / count_bytes(result['hex']) | |||||
assert_fee_amount( | |||||
result2['fee'], FromHex(CTransaction(), result2['hex']).billable_size(), 2 * result_fee_rate) | |||||
assert_fee_amount( | assert_fee_amount( | ||||
result3['fee'], FromHex(CTransaction(), result3['hex']).billable_size(), 10 * result_fee_rate) | result3['fee'], FromHex(CTransaction(), result3['hex']).billable_size(), 10 * min_relay_tx_fee) | ||||
# | # | ||||
# Test address reuse option # | # Test address reuse option # | ||||
# | # | ||||
result3 = self.nodes[3].fundrawtransaction( | result3 = self.nodes[3].fundrawtransaction( | ||||
rawtx, {"reserveChangeKey": False}) | rawtx, {"reserveChangeKey": False}) | ||||
res_dec = self.nodes[0].decoderawtransaction(result3["hex"]) | res_dec = self.nodes[0].decoderawtransaction(result3["hex"]) | ||||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |