|
|
@ -125,9 +125,9 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
tx1b_hex = txToHex(tx1b) |
|
|
|
tx1b_hex = txToHex(tx1b) |
|
|
|
|
|
|
|
|
|
|
|
# This will raise an exception due to insufficient fee |
|
|
|
# This will raise an exception due to insufficient fee |
|
|
|
assert_raises_jsonrpc(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, True) |
|
|
|
# This will raise an exception due to transaction replacement being disabled |
|
|
|
# This will raise an exception due to transaction replacement being disabled |
|
|
|
assert_raises_jsonrpc(-26, "txn-mempool-conflict", self.nodes[1].sendrawtransaction, tx1b_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[1].sendrawtransaction, tx1b_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
# Extra 0.1 BTC fee |
|
|
|
# Extra 0.1 BTC fee |
|
|
|
tx1b = CTransaction() |
|
|
|
tx1b = CTransaction() |
|
|
@ -135,7 +135,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
tx1b.vout = [CTxOut(int(0.9*COIN), CScript([b'b']))] |
|
|
|
tx1b.vout = [CTxOut(int(0.9*COIN), CScript([b'b']))] |
|
|
|
tx1b_hex = txToHex(tx1b) |
|
|
|
tx1b_hex = txToHex(tx1b) |
|
|
|
# Replacement still disabled even with "enough fee" |
|
|
|
# Replacement still disabled even with "enough fee" |
|
|
|
assert_raises_jsonrpc(-26, "txn-mempool-conflict", self.nodes[1].sendrawtransaction, tx1b_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[1].sendrawtransaction, tx1b_hex, True) |
|
|
|
# Works when enabled |
|
|
|
# Works when enabled |
|
|
|
tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, True) |
|
|
|
tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, True) |
|
|
|
|
|
|
|
|
|
|
@ -178,7 +178,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
dbl_tx_hex = txToHex(dbl_tx) |
|
|
|
dbl_tx_hex = txToHex(dbl_tx) |
|
|
|
|
|
|
|
|
|
|
|
# This will raise an exception due to insufficient fee |
|
|
|
# This will raise an exception due to insufficient fee |
|
|
|
assert_raises_jsonrpc(-26, "insufficient fee", self.nodes[0].sendrawtransaction, dbl_tx_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, dbl_tx_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
# Accepted with sufficient fee |
|
|
|
# Accepted with sufficient fee |
|
|
|
dbl_tx = CTransaction() |
|
|
|
dbl_tx = CTransaction() |
|
|
@ -239,7 +239,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
dbl_tx.vout = [CTxOut(initial_nValue - fee*n, CScript([1]))] |
|
|
|
dbl_tx.vout = [CTxOut(initial_nValue - fee*n, CScript([1]))] |
|
|
|
dbl_tx_hex = txToHex(dbl_tx) |
|
|
|
dbl_tx_hex = txToHex(dbl_tx) |
|
|
|
# This will raise an exception due to insufficient fee |
|
|
|
# This will raise an exception due to insufficient fee |
|
|
|
assert_raises_jsonrpc(-26, "insufficient fee", self.nodes[0].sendrawtransaction, dbl_tx_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, dbl_tx_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
# 1 BTC fee is enough |
|
|
|
# 1 BTC fee is enough |
|
|
|
dbl_tx = CTransaction() |
|
|
|
dbl_tx = CTransaction() |
|
|
@ -267,7 +267,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
dbl_tx.vout = [CTxOut(initial_nValue - 2*fee*n, CScript([1]))] |
|
|
|
dbl_tx.vout = [CTxOut(initial_nValue - 2*fee*n, CScript([1]))] |
|
|
|
dbl_tx_hex = txToHex(dbl_tx) |
|
|
|
dbl_tx_hex = txToHex(dbl_tx) |
|
|
|
# This will raise an exception |
|
|
|
# This will raise an exception |
|
|
|
assert_raises_jsonrpc(-26, "too many potential replacements", self.nodes[0].sendrawtransaction, dbl_tx_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "too many potential replacements", self.nodes[0].sendrawtransaction, dbl_tx_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
for tx in tree_txs: |
|
|
|
for tx in tree_txs: |
|
|
|
tx.rehash() |
|
|
|
tx.rehash() |
|
|
@ -291,7 +291,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
tx1b_hex = txToHex(tx1b) |
|
|
|
tx1b_hex = txToHex(tx1b) |
|
|
|
|
|
|
|
|
|
|
|
# This will raise an exception due to insufficient fee |
|
|
|
# This will raise an exception due to insufficient fee |
|
|
|
assert_raises_jsonrpc(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
def test_spends_of_conflicting_outputs(self): |
|
|
|
def test_spends_of_conflicting_outputs(self): |
|
|
|
"""Replacements that spend conflicting tx outputs are rejected""" |
|
|
|
"""Replacements that spend conflicting tx outputs are rejected""" |
|
|
@ -314,7 +314,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
tx2_hex = txToHex(tx2) |
|
|
|
tx2_hex = txToHex(tx2) |
|
|
|
|
|
|
|
|
|
|
|
# This will raise an exception |
|
|
|
# This will raise an exception |
|
|
|
assert_raises_jsonrpc(-26, "bad-txns-spends-conflicting-tx", self.nodes[0].sendrawtransaction, tx2_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "bad-txns-spends-conflicting-tx", self.nodes[0].sendrawtransaction, tx2_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
# Spend tx1a's output to test the indirect case. |
|
|
|
# Spend tx1a's output to test the indirect case. |
|
|
|
tx1b = CTransaction() |
|
|
|
tx1b = CTransaction() |
|
|
@ -331,7 +331,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
tx2_hex = txToHex(tx2) |
|
|
|
tx2_hex = txToHex(tx2) |
|
|
|
|
|
|
|
|
|
|
|
# This will raise an exception |
|
|
|
# This will raise an exception |
|
|
|
assert_raises_jsonrpc(-26, "bad-txns-spends-conflicting-tx", self.nodes[0].sendrawtransaction, tx2_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "bad-txns-spends-conflicting-tx", self.nodes[0].sendrawtransaction, tx2_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
def test_new_unconfirmed_inputs(self): |
|
|
|
def test_new_unconfirmed_inputs(self): |
|
|
|
"""Replacements that add new unconfirmed inputs are rejected""" |
|
|
|
"""Replacements that add new unconfirmed inputs are rejected""" |
|
|
@ -350,7 +350,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
tx2_hex = txToHex(tx2) |
|
|
|
tx2_hex = txToHex(tx2) |
|
|
|
|
|
|
|
|
|
|
|
# This will raise an exception |
|
|
|
# This will raise an exception |
|
|
|
assert_raises_jsonrpc(-26, "replacement-adds-unconfirmed", self.nodes[0].sendrawtransaction, tx2_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "replacement-adds-unconfirmed", self.nodes[0].sendrawtransaction, tx2_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
def test_too_many_replacements(self): |
|
|
|
def test_too_many_replacements(self): |
|
|
|
"""Replacements that evict too many transactions are rejected""" |
|
|
|
"""Replacements that evict too many transactions are rejected""" |
|
|
@ -396,7 +396,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
double_tx_hex = txToHex(double_tx) |
|
|
|
double_tx_hex = txToHex(double_tx) |
|
|
|
|
|
|
|
|
|
|
|
# This will raise an exception |
|
|
|
# This will raise an exception |
|
|
|
assert_raises_jsonrpc(-26, "too many potential replacements", self.nodes[0].sendrawtransaction, double_tx_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "too many potential replacements", self.nodes[0].sendrawtransaction, double_tx_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
# If we remove an input, it should pass |
|
|
|
# If we remove an input, it should pass |
|
|
|
double_tx = CTransaction() |
|
|
|
double_tx = CTransaction() |
|
|
@ -423,7 +423,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
tx1b_hex = txToHex(tx1b) |
|
|
|
tx1b_hex = txToHex(tx1b) |
|
|
|
|
|
|
|
|
|
|
|
# This will raise an exception |
|
|
|
# This will raise an exception |
|
|
|
assert_raises_jsonrpc(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx1b_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx1b_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
tx1_outpoint = make_utxo(self.nodes[0], int(1.1*COIN)) |
|
|
|
tx1_outpoint = make_utxo(self.nodes[0], int(1.1*COIN)) |
|
|
|
|
|
|
|
|
|
|
@ -441,7 +441,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
tx2b_hex = txToHex(tx2b) |
|
|
|
tx2b_hex = txToHex(tx2b) |
|
|
|
|
|
|
|
|
|
|
|
# This will raise an exception |
|
|
|
# This will raise an exception |
|
|
|
assert_raises_jsonrpc(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx2b_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx2b_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
# Now create a new transaction that spends from tx1a and tx2a |
|
|
|
# Now create a new transaction that spends from tx1a and tx2a |
|
|
|
# opt-in on one of the inputs |
|
|
|
# opt-in on one of the inputs |
|
|
@ -493,7 +493,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
tx1b_hex = txToHex(tx1b) |
|
|
|
tx1b_hex = txToHex(tx1b) |
|
|
|
|
|
|
|
|
|
|
|
# Verify tx1b cannot replace tx1a. |
|
|
|
# Verify tx1b cannot replace tx1a. |
|
|
|
assert_raises_jsonrpc(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
# Use prioritisetransaction to set tx1a's fee to 0. |
|
|
|
# Use prioritisetransaction to set tx1a's fee to 0. |
|
|
|
self.nodes[0].prioritisetransaction(txid=tx1a_txid, fee_delta=int(-0.1*COIN)) |
|
|
|
self.nodes[0].prioritisetransaction(txid=tx1a_txid, fee_delta=int(-0.1*COIN)) |
|
|
@ -520,7 +520,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): |
|
|
|
tx2b_hex = txToHex(tx2b) |
|
|
|
tx2b_hex = txToHex(tx2b) |
|
|
|
|
|
|
|
|
|
|
|
# Verify tx2b cannot replace tx2a. |
|
|
|
# Verify tx2b cannot replace tx2a. |
|
|
|
assert_raises_jsonrpc(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx2b_hex, True) |
|
|
|
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx2b_hex, True) |
|
|
|
|
|
|
|
|
|
|
|
# Now prioritise tx2b to have a higher modified fee |
|
|
|
# Now prioritise tx2b to have a higher modified fee |
|
|
|
self.nodes[0].prioritisetransaction(txid=tx2b.hash, fee_delta=int(0.1*COIN)) |
|
|
|
self.nodes[0].prioritisetransaction(txid=tx2b.hash, fee_delta=int(0.1*COIN)) |
|
|
|