Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_rawtransaction.py
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | class RawTransactionsTest(BitcoinTestFramework): | ||||
def run_test(self): | def run_test(self): | ||||
self.log.info( | self.log.info( | ||||
'prepare some coins for multiple *rawtransaction commands') | 'prepare some coins for multiple *rawtransaction commands') | ||||
self.nodes[2].generate(1) | self.nodes[2].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[0].generate(101) | self.nodes[0].generate(101) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.5) | self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1500000) | ||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0) | self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1000000) | ||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 5.0) | self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 5000000) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[0].generate(5) | self.nodes[0].generate(5) | ||||
self.sync_all() | self.sync_all() | ||||
self.log.info( | self.log.info( | ||||
'Test getrawtransaction on genesis block coinbase returns an error') | 'Test getrawtransaction on genesis block coinbase returns an error') | ||||
block = self.nodes[0].getblock(self.nodes[0].getblockhash(0)) | block = self.nodes[0].getblock(self.nodes[0].getblockhash(0)) | ||||
assert_raises_rpc_error(-5, "The genesis block coinbase is not considered an ordinary transaction", | assert_raises_rpc_error(-5, "The genesis block coinbase is not considered an ordinary transaction", | ||||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
######################################### | ######################################### | ||||
# sendrawtransaction with missing input # | # sendrawtransaction with missing input # | ||||
######################################### | ######################################### | ||||
self.log.info('sendrawtransaction with missing input') | self.log.info('sendrawtransaction with missing input') | ||||
# won't exists | # won't exists | ||||
inputs = [ | inputs = [ | ||||
{'txid': "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout': 1}] | {'txid': "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout': 1}] | ||||
outputs = {self.nodes[0].getnewaddress(): 4.998} | outputs = {self.nodes[0].getnewaddress(): 4998000} | ||||
rawtx = self.nodes[2].createrawtransaction(inputs, outputs) | rawtx = self.nodes[2].createrawtransaction(inputs, outputs) | ||||
rawtx = pad_raw_tx(rawtx) | rawtx = pad_raw_tx(rawtx) | ||||
rawtx = self.nodes[2].signrawtransactionwithwallet(rawtx) | rawtx = self.nodes[2].signrawtransactionwithwallet(rawtx) | ||||
# This will raise an exception since there are missing inputs | # This will raise an exception since there are missing inputs | ||||
assert_raises_rpc_error(-25, | assert_raises_rpc_error(-25, | ||||
"bad-txns-inputs-missingorspent", | "bad-txns-inputs-missingorspent", | ||||
self.nodes[2].sendrawtransaction, | self.nodes[2].sendrawtransaction, | ||||
rawtx['hex']) | rawtx['hex']) | ||||
##################################### | ##################################### | ||||
# getrawtransaction with block hash # | # getrawtransaction with block hash # | ||||
##################################### | ##################################### | ||||
# make a tx by sending then generate 2 blocks; block1 has the tx in it | # make a tx by sending then generate 2 blocks; block1 has the tx in it | ||||
tx = self.nodes[2].sendtoaddress(self.nodes[1].getnewaddress(), 1) | tx = self.nodes[2].sendtoaddress( | ||||
self.nodes[1].getnewaddress(), 1000000) | |||||
block1, block2 = self.nodes[2].generate(2) | block1, block2 = self.nodes[2].generate(2) | ||||
self.sync_all() | self.sync_all() | ||||
# We should be able to get the raw transaction by providing the correct | # We should be able to get the raw transaction by providing the correct | ||||
# block | # block | ||||
gottx = self.nodes[0].getrawtransaction(tx, True, block1) | gottx = self.nodes[0].getrawtransaction(tx, True, block1) | ||||
assert_equal(gottx['txid'], tx) | assert_equal(gottx['txid'], tx) | ||||
assert_equal(gottx['in_active_chain'], True) | assert_equal(gottx['in_active_chain'], True) | ||||
# We should not have the 'in_active_chain' flag when we don't provide a | # We should not have the 'in_active_chain' flag when we don't provide a | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
mSigObj = self.nodes[2].addmultisigaddress( | mSigObj = self.nodes[2].addmultisigaddress( | ||||
2, [addr1Obj['pubkey'], addr1])['address'] | 2, [addr1Obj['pubkey'], addr1])['address'] | ||||
# use balance deltas instead of absolute values | # use balance deltas instead of absolute values | ||||
bal = self.nodes[2].getbalance() | bal = self.nodes[2].getbalance() | ||||
# send 1.2 BCH to msig adr | # send 1.2 BCH to msig adr | ||||
txId = self.nodes[0].sendtoaddress(mSigObj, 1.2) | txId = self.nodes[0].sendtoaddress(mSigObj, 1200000) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
# node2 has both keys of the 2of2 ms addr., tx should affect the | # node2 has both keys of the 2of2 ms addr., tx should affect the | ||||
# balance | # balance | ||||
assert_equal(self.nodes[2].getbalance(), bal + Decimal('1.20000000')) | assert_equal(self.nodes[2].getbalance(), bal + Decimal('1200000.00')) | ||||
# 2of3 test from different nodes | # 2of3 test from different nodes | ||||
bal = self.nodes[2].getbalance() | bal = self.nodes[2].getbalance() | ||||
addr1 = self.nodes[1].getnewaddress() | addr1 = self.nodes[1].getnewaddress() | ||||
addr2 = self.nodes[2].getnewaddress() | addr2 = self.nodes[2].getnewaddress() | ||||
addr3 = self.nodes[2].getnewaddress() | addr3 = self.nodes[2].getnewaddress() | ||||
addr1Obj = self.nodes[1].getaddressinfo(addr1) | addr1Obj = self.nodes[1].getaddressinfo(addr1) | ||||
addr2Obj = self.nodes[2].getaddressinfo(addr2) | addr2Obj = self.nodes[2].getaddressinfo(addr2) | ||||
addr3Obj = self.nodes[2].getaddressinfo(addr3) | addr3Obj = self.nodes[2].getaddressinfo(addr3) | ||||
mSigObj = self.nodes[2].addmultisigaddress( | mSigObj = self.nodes[2].addmultisigaddress( | ||||
2, [addr1Obj['pubkey'], addr2Obj['pubkey'], addr3Obj['pubkey']])['address'] | 2, [addr1Obj['pubkey'], addr2Obj['pubkey'], addr3Obj['pubkey']])['address'] | ||||
txId = self.nodes[0].sendtoaddress(mSigObj, 2.2) | txId = self.nodes[0].sendtoaddress(mSigObj, 2200000) | ||||
decTx = self.nodes[0].gettransaction(txId) | decTx = self.nodes[0].gettransaction(txId) | ||||
rawTx = self.nodes[0].decoderawtransaction(decTx['hex']) | rawTx = self.nodes[0].decoderawtransaction(decTx['hex']) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
# THIS IS AN INCOMPLETE FEATURE | # THIS IS AN INCOMPLETE FEATURE | ||||
# NODE2 HAS TWO OF THREE KEY AND THE FUNDS SHOULD BE SPENDABLE AND | # NODE2 HAS TWO OF THREE KEY AND THE FUNDS SHOULD BE SPENDABLE AND | ||||
# COUNT AT BALANCE CALCULATION | # COUNT AT BALANCE CALCULATION | ||||
# for now, assume the funds of a 2of3 multisig tx are not marked as | # for now, assume the funds of a 2of3 multisig tx are not marked as | ||||
# spendable | # spendable | ||||
assert_equal(self.nodes[2].getbalance(), bal) | assert_equal(self.nodes[2].getbalance(), bal) | ||||
txDetails = self.nodes[0].gettransaction(txId, True) | txDetails = self.nodes[0].gettransaction(txId, True) | ||||
rawTx = self.nodes[0].decoderawtransaction(txDetails['hex']) | rawTx = self.nodes[0].decoderawtransaction(txDetails['hex']) | ||||
vout = next(o for o in rawTx['vout'] | vout = next(o for o in rawTx['vout'] | ||||
if o['value'] == Decimal('2.20000000')) | if o['value'] == Decimal('2200000.00')) | ||||
bal = self.nodes[0].getbalance() | bal = self.nodes[0].getbalance() | ||||
inputs = [{ | inputs = [{ | ||||
"txid": txId, | "txid": txId, | ||||
"vout": vout['n'], | "vout": vout['n'], | ||||
"scriptPubKey": vout['scriptPubKey']['hex'], | "scriptPubKey": vout['scriptPubKey']['hex'], | ||||
"amount": vout['value'], | "amount": vout['value'], | ||||
}] | }] | ||||
outputs = {self.nodes[0].getnewaddress(): 2.19} | outputs = {self.nodes[0].getnewaddress(): 2190000} | ||||
rawTx = self.nodes[2].createrawtransaction(inputs, outputs) | rawTx = self.nodes[2].createrawtransaction(inputs, outputs) | ||||
rawTxPartialSigned = self.nodes[1].signrawtransactionwithwallet( | rawTxPartialSigned = self.nodes[1].signrawtransactionwithwallet( | ||||
rawTx, inputs) | rawTx, inputs) | ||||
# node1 only has one key, can't comp. sign the tx | # node1 only has one key, can't comp. sign the tx | ||||
assert_equal(rawTxPartialSigned['complete'], False) | assert_equal(rawTxPartialSigned['complete'], False) | ||||
rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx, inputs) | rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx, inputs) | ||||
# node2 can sign the tx compl., own two of three keys | # node2 can sign the tx compl., own two of three keys | ||||
assert_equal(rawTxSigned['complete'], True) | assert_equal(rawTxSigned['complete'], True) | ||||
self.nodes[2].sendrawtransaction(rawTxSigned['hex']) | self.nodes[2].sendrawtransaction(rawTxSigned['hex']) | ||||
rawTx = self.nodes[0].decoderawtransaction(rawTxSigned['hex']) | rawTx = self.nodes[0].decoderawtransaction(rawTxSigned['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(self.nodes[0].getbalance(), bal + Decimal( | assert_equal(self.nodes[0].getbalance(), bal + Decimal( | ||||
'50.00000000') + Decimal('2.19000000')) # block reward + tx | '50000000.00') + Decimal('2190000.00')) # block reward + tx | ||||
rawTxBlock = self.nodes[0].getblock(self.nodes[0].getbestblockhash()) | rawTxBlock = self.nodes[0].getblock(self.nodes[0].getbestblockhash()) | ||||
# 2of2 test for combining transactions | # 2of2 test for combining transactions | ||||
bal = self.nodes[2].getbalance() | bal = self.nodes[2].getbalance() | ||||
addr1 = self.nodes[1].getnewaddress() | addr1 = self.nodes[1].getnewaddress() | ||||
addr2 = self.nodes[2].getnewaddress() | addr2 = self.nodes[2].getnewaddress() | ||||
addr1Obj = self.nodes[1].getaddressinfo(addr1) | addr1Obj = self.nodes[1].getaddressinfo(addr1) | ||||
addr2Obj = self.nodes[2].getaddressinfo(addr2) | addr2Obj = self.nodes[2].getaddressinfo(addr2) | ||||
self.nodes[1].addmultisigaddress( | self.nodes[1].addmultisigaddress( | ||||
2, [addr1Obj['pubkey'], addr2Obj['pubkey']])['address'] | 2, [addr1Obj['pubkey'], addr2Obj['pubkey']])['address'] | ||||
mSigObj = self.nodes[2].addmultisigaddress( | mSigObj = self.nodes[2].addmultisigaddress( | ||||
2, [addr1Obj['pubkey'], addr2Obj['pubkey']])['address'] | 2, [addr1Obj['pubkey'], addr2Obj['pubkey']])['address'] | ||||
mSigObjValid = self.nodes[2].getaddressinfo(mSigObj) | mSigObjValid = self.nodes[2].getaddressinfo(mSigObj) | ||||
txId = self.nodes[0].sendtoaddress(mSigObj, 2.2) | txId = self.nodes[0].sendtoaddress(mSigObj, 2200000) | ||||
decTx = self.nodes[0].gettransaction(txId) | decTx = self.nodes[0].gettransaction(txId) | ||||
rawTx2 = self.nodes[0].decoderawtransaction(decTx['hex']) | rawTx2 = self.nodes[0].decoderawtransaction(decTx['hex']) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
# the funds of a 2of2 multisig tx should not be marked as spendable | # the funds of a 2of2 multisig tx should not be marked as spendable | ||||
assert_equal(self.nodes[2].getbalance(), bal) | assert_equal(self.nodes[2].getbalance(), bal) | ||||
txDetails = self.nodes[0].gettransaction(txId, True) | txDetails = self.nodes[0].gettransaction(txId, True) | ||||
rawTx2 = self.nodes[0].decoderawtransaction(txDetails['hex']) | rawTx2 = self.nodes[0].decoderawtransaction(txDetails['hex']) | ||||
vout = next(o for o in rawTx2['vout'] | vout = next(o for o in rawTx2['vout'] | ||||
if o['value'] == Decimal('2.20000000')) | if o['value'] == Decimal('2200000.00')) | ||||
bal = self.nodes[0].getbalance() | bal = self.nodes[0].getbalance() | ||||
inputs = [{"txid": txId, "vout": vout['n'], "scriptPubKey": vout['scriptPubKey'] | inputs = [{"txid": txId, "vout": vout['n'], "scriptPubKey": vout['scriptPubKey'] | ||||
['hex'], "redeemScript": mSigObjValid['hex'], "amount": vout['value']}] | ['hex'], "redeemScript": mSigObjValid['hex'], "amount": vout['value']}] | ||||
outputs = {self.nodes[0].getnewaddress(): 2.19} | outputs = {self.nodes[0].getnewaddress(): 2190000} | ||||
rawTx2 = self.nodes[2].createrawtransaction(inputs, outputs) | rawTx2 = self.nodes[2].createrawtransaction(inputs, outputs) | ||||
rawTxPartialSigned1 = self.nodes[1].signrawtransactionwithwallet( | rawTxPartialSigned1 = self.nodes[1].signrawtransactionwithwallet( | ||||
rawTx2, inputs) | rawTx2, inputs) | ||||
self.log.debug(rawTxPartialSigned1) | self.log.debug(rawTxPartialSigned1) | ||||
# node1 only has one key, can't comp. sign the tx | # node1 only has one key, can't comp. sign the tx | ||||
assert_equal(rawTxPartialSigned1['complete'], False) | assert_equal(rawTxPartialSigned1['complete'], False) | ||||
rawTxPartialSigned2 = self.nodes[2].signrawtransactionwithwallet( | rawTxPartialSigned2 = self.nodes[2].signrawtransactionwithwallet( | ||||
rawTx2, inputs) | rawTx2, inputs) | ||||
self.log.debug(rawTxPartialSigned2) | self.log.debug(rawTxPartialSigned2) | ||||
# node2 only has one key, can't comp. sign the tx | # node2 only has one key, can't comp. sign the tx | ||||
assert_equal(rawTxPartialSigned2['complete'], False) | assert_equal(rawTxPartialSigned2['complete'], False) | ||||
rawTxComb = self.nodes[2].combinerawtransaction( | rawTxComb = self.nodes[2].combinerawtransaction( | ||||
[rawTxPartialSigned1['hex'], rawTxPartialSigned2['hex']]) | [rawTxPartialSigned1['hex'], rawTxPartialSigned2['hex']]) | ||||
self.log.debug(rawTxComb) | self.log.debug(rawTxComb) | ||||
self.nodes[2].sendrawtransaction(rawTxComb) | self.nodes[2].sendrawtransaction(rawTxComb) | ||||
rawTx2 = self.nodes[0].decoderawtransaction(rawTxComb) | rawTx2 = self.nodes[0].decoderawtransaction(rawTxComb) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
assert_equal(self.nodes[0].getbalance( | assert_equal(self.nodes[0].getbalance( | ||||
), bal + Decimal('50.00000000') + Decimal('2.19000000')) # block reward + tx | ), bal + Decimal('50000000.00') + Decimal('2190000.00')) # block reward + tx | ||||
# getrawtransaction tests | # getrawtransaction tests | ||||
# 1. valid parameters - only supply txid | # 1. valid parameters - only supply txid | ||||
txId = rawTx["txid"] | txId = rawTx["txid"] | ||||
assert_equal( | assert_equal( | ||||
self.nodes[0].getrawtransaction(txId), rawTxSigned['hex']) | self.nodes[0].getrawtransaction(txId), rawTxSigned['hex']) | ||||
# 2. valid parameters - supply txid and 0 for non-verbose | # 2. valid parameters - supply txid and 0 for non-verbose | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
tx.nVersion = 0x7fffffff | tx.nVersion = 0x7fffffff | ||||
rawtx = ToHex(tx) | rawtx = ToHex(tx) | ||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx) | decrawtx = self.nodes[0].decoderawtransaction(rawtx) | ||||
assert_equal(decrawtx['version'], 0x7fffffff) | assert_equal(decrawtx['version'], 0x7fffffff) | ||||
self.log.info('sendrawtransaction/testmempoolaccept with maxfeerate') | self.log.info('sendrawtransaction/testmempoolaccept with maxfeerate') | ||||
# Test a transaction with a small fee. | # Test a transaction with a small fee. | ||||
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0) | txId = self.nodes[0].sendtoaddress( | ||||
self.nodes[2].getnewaddress(), 1000000) | |||||
rawTx = self.nodes[0].getrawtransaction(txId, True) | rawTx = self.nodes[0].getrawtransaction(txId, True) | ||||
vout = next(o for o in rawTx['vout'] | vout = next(o for o in rawTx['vout'] | ||||
if o['value'] == Decimal('1.00000000')) | if o['value'] == Decimal('1000000.00')) | ||||
self.sync_all() | self.sync_all() | ||||
inputs = [{"txid": txId, "vout": vout['n']}] | inputs = [{"txid": txId, "vout": vout['n']}] | ||||
# Fee 10,000 satoshis, (1 - (10000 sat * 0.00000001 BCH/sat)) = 0.9999 | # Fee 10,000 satoshis, (1 - (10000 sat * 0.00000001 BCH/sat)) = 0.9999 | ||||
outputs = {self.nodes[0].getnewaddress(): Decimal("0.99990000")} | outputs = {self.nodes[0].getnewaddress(): Decimal("999900.00")} | ||||
rawTx = self.nodes[2].createrawtransaction(inputs, outputs) | rawTx = self.nodes[2].createrawtransaction(inputs, outputs) | ||||
rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx) | rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx) | ||||
assert_equal(rawTxSigned['complete'], True) | assert_equal(rawTxSigned['complete'], True) | ||||
# Fee 10,000 satoshis, ~200 b transaction, fee rate should land around 50 sat/byte = 0.00050000 BCH/kB | # Fee 10,000 satoshis, ~200 b transaction, fee rate should land around 50 sat/byte = 0.00050000 BCH/kB | ||||
# Thus, testmempoolaccept should reject | # Thus, testmempoolaccept should reject | ||||
testres = self.nodes[2].testmempoolaccept( | testres = self.nodes[2].testmempoolaccept( | ||||
[rawTxSigned['hex']], 0.00050000)[0] | [rawTxSigned['hex']], 500.00)[0] | ||||
assert_equal(testres['allowed'], False) | assert_equal(testres['allowed'], False) | ||||
assert_equal(testres['reject-reason'], 'absurdly-high-fee') | assert_equal(testres['reject-reason'], 'absurdly-high-fee') | ||||
# and sendrawtransaction should throw | # and sendrawtransaction should throw | ||||
assert_raises_rpc_error(-26, | assert_raises_rpc_error(-26, | ||||
"absurdly-high-fee", | "absurdly-high-fee", | ||||
self.nodes[2].sendrawtransaction, | self.nodes[2].sendrawtransaction, | ||||
rawTxSigned['hex'], | rawTxSigned['hex'], | ||||
0.00001000) | 10.00) | ||||
# and the following calls should both succeed | # and the following calls should both succeed | ||||
testres = self.nodes[2].testmempoolaccept( | testres = self.nodes[2].testmempoolaccept( | ||||
rawtxs=[rawTxSigned['hex']])[0] | rawtxs=[rawTxSigned['hex']])[0] | ||||
assert_equal(testres['allowed'], True) | assert_equal(testres['allowed'], True) | ||||
self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex']) | self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex']) | ||||
# Test a transaction with a large fee. | # Test a transaction with a large fee. | ||||
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0) | txId = self.nodes[0].sendtoaddress( | ||||
self.nodes[2].getnewaddress(), 1000000) | |||||
rawTx = self.nodes[0].getrawtransaction(txId, True) | rawTx = self.nodes[0].getrawtransaction(txId, True) | ||||
vout = next(o for o in rawTx['vout'] | vout = next(o for o in rawTx['vout'] | ||||
if o['value'] == Decimal('1.00000000')) | if o['value'] == Decimal('1000000.00')) | ||||
self.sync_all() | self.sync_all() | ||||
inputs = [{"txid": txId, "vout": vout['n']}] | inputs = [{"txid": txId, "vout": vout['n']}] | ||||
# Fee 2,000,000 satoshis, (1 - (2000000 sat * 0.00000001 BCH/sat)) = | # Fee 2,000,000 satoshis, (1 - (2000000 sat * 0.00000001 BCH/sat)) = | ||||
# 0.98 | # 0.98 | ||||
outputs = {self.nodes[0].getnewaddress(): Decimal("0.98000000")} | outputs = {self.nodes[0].getnewaddress(): Decimal("980000.00")} | ||||
rawTx = self.nodes[2].createrawtransaction(inputs, outputs) | rawTx = self.nodes[2].createrawtransaction(inputs, outputs) | ||||
rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx) | rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx) | ||||
assert_equal(rawTxSigned['complete'], True) | assert_equal(rawTxSigned['complete'], True) | ||||
# Fee 2,000,000 satoshis, ~100 b transaction, fee rate should land around 20,000 sat/byte = 0.20000000 BCH/kB | # Fee 2,000,000 satoshis, ~100 b transaction, fee rate should land around 20,000 sat/byte = 0.20000000 BCH/kB | ||||
# Thus, testmempoolaccept should reject | # Thus, testmempoolaccept should reject | ||||
testres = self.nodes[2].testmempoolaccept([rawTxSigned['hex']])[0] | testres = self.nodes[2].testmempoolaccept([rawTxSigned['hex']])[0] | ||||
assert_equal(testres['allowed'], False) | assert_equal(testres['allowed'], False) | ||||
assert_equal(testres['reject-reason'], 'absurdly-high-fee') | assert_equal(testres['reject-reason'], 'absurdly-high-fee') | ||||
# and sendrawtransaction should throw | # and sendrawtransaction should throw | ||||
assert_raises_rpc_error(-26, | assert_raises_rpc_error(-26, | ||||
"absurdly-high-fee", | "absurdly-high-fee", | ||||
self.nodes[2].sendrawtransaction, | self.nodes[2].sendrawtransaction, | ||||
rawTxSigned['hex']) | rawTxSigned['hex']) | ||||
# and the following calls should both succeed | # and the following calls should both succeed | ||||
testres = self.nodes[2].testmempoolaccept( | testres = self.nodes[2].testmempoolaccept( | ||||
rawtxs=[rawTxSigned['hex']], maxfeerate='0.20000000')[0] | rawtxs=[rawTxSigned['hex']], maxfeerate='200000.00')[0] | ||||
assert_equal(testres['allowed'], True) | assert_equal(testres['allowed'], True) | ||||
self.nodes[2].sendrawtransaction( | self.nodes[2].sendrawtransaction( | ||||
hexstring=rawTxSigned['hex'], | hexstring=rawTxSigned['hex'], | ||||
maxfeerate='0.20000000') | maxfeerate='200000.00') | ||||
########################################## | ########################################## | ||||
# Decoding weird scripts in transactions # | # Decoding weird scripts in transactions # | ||||
########################################## | ########################################## | ||||
self.log.info('Decode correctly-formatted but weird transactions') | self.log.info('Decode correctly-formatted but weird transactions') | ||||
tx = CTransaction() | tx = CTransaction() | ||||
# empty | # empty | ||||
Show All 20 Lines |