2 # Copyright (c) 2014-2017 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 """Test the RBF code."""
7 from test_framework
.test_framework
import BitcoinTestFramework
8 from test_framework
.util
import *
9 from test_framework
.script
import *
10 from test_framework
.mininode
import *
12 MAX_REPLACEMENT_LIMIT
= 100
15 return bytes_to_hex_str(tx
.serialize())
17 def make_utxo(node
, amount
, confirmed
=True, scriptPubKey
=CScript([1])):
18 """Create a txout with a given amount and scriptPubKey
20 Mines coins as needed.
22 confirmed - txouts created will be confirmed in the blockchain;
23 unconfirmed otherwise.
26 while node
.getbalance() < satoshi_round((amount
+ fee
)/COIN
):
29 new_addr
= node
.getnewaddress()
30 txid
= node
.sendtoaddress(new_addr
, satoshi_round((amount
+fee
)/COIN
))
31 tx1
= node
.getrawtransaction(txid
, 1)
35 for i
, txout
in enumerate(tx1
['vout']):
36 if txout
['scriptPubKey']['addresses'] == [new_addr
]:
41 tx2
.vin
= [CTxIn(COutPoint(txid
, i
))]
42 tx2
.vout
= [CTxOut(amount
, scriptPubKey
)]
45 signed_tx
= node
.signrawtransaction(txToHex(tx2
))
47 txid
= node
.sendrawtransaction(signed_tx
['hex'], True)
49 # If requested, ensure txouts are confirmed.
51 mempool_size
= len(node
.getrawmempool())
52 while mempool_size
> 0:
54 new_size
= len(node
.getrawmempool())
55 # Error out if we have something stuck in the mempool, as this
56 # would likely be a bug.
57 assert(new_size
< mempool_size
)
58 mempool_size
= new_size
60 return COutPoint(int(txid
, 16), 0)
62 class ReplaceByFeeTest(BitcoinTestFramework
):
64 def set_test_params(self
):
66 self
.extra_args
= [["-maxorphantx=1000",
67 "-whitelist=127.0.0.1",
68 "-limitancestorcount=50",
69 "-limitancestorsize=101",
70 "-limitdescendantcount=200",
71 "-limitdescendantsize=101"],
72 ["-mempoolreplacement=0"]]
76 self
.nodes
[0].generate(1)
78 make_utxo(self
.nodes
[0], 1*COIN
)
80 # Ensure nodes are synced
83 self
.log
.info("Running test simple doublespend...")
84 self
.test_simple_doublespend()
86 self
.log
.info("Running test doublespend chain...")
87 self
.test_doublespend_chain()
89 self
.log
.info("Running test doublespend tree...")
90 self
.test_doublespend_tree()
92 self
.log
.info("Running test replacement feeperkb...")
93 self
.test_replacement_feeperkb()
95 self
.log
.info("Running test spends of conflicting outputs...")
96 self
.test_spends_of_conflicting_outputs()
98 self
.log
.info("Running test new unconfirmed inputs...")
99 self
.test_new_unconfirmed_inputs()
101 self
.log
.info("Running test too many replacements...")
102 self
.test_too_many_replacements()
104 self
.log
.info("Running test opt-in...")
107 self
.log
.info("Running test RPC...")
110 self
.log
.info("Running test prioritised transactions...")
111 self
.test_prioritised_transactions()
113 self
.log
.info("Passed")
115 def test_simple_doublespend(self
):
116 """Simple doublespend"""
117 tx0_outpoint
= make_utxo(self
.nodes
[0], int(1.1*COIN
))
119 # make_utxo may have generated a bunch of blocks, so we need to sync
120 # before we can spend the coins generated, or else the resulting
121 # transactions might not be accepted by our peers.
124 tx1a
= CTransaction()
125 tx1a
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
126 tx1a
.vout
= [CTxOut(1*COIN
, CScript([b
'a']))]
127 tx1a_hex
= txToHex(tx1a
)
128 tx1a_txid
= self
.nodes
[0].sendrawtransaction(tx1a_hex
, True)
132 # Should fail because we haven't changed the fee
133 tx1b
= CTransaction()
134 tx1b
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
135 tx1b
.vout
= [CTxOut(1*COIN
, CScript([b
'b']))]
136 tx1b_hex
= txToHex(tx1b
)
138 # This will raise an exception due to insufficient fee
139 assert_raises_rpc_error(-26, "insufficient fee", self
.nodes
[0].sendrawtransaction
, tx1b_hex
, True)
140 # This will raise an exception due to transaction replacement being disabled
141 assert_raises_rpc_error(-26, "txn-mempool-conflict", self
.nodes
[1].sendrawtransaction
, tx1b_hex
, True)
144 tx1b
= CTransaction()
145 tx1b
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
146 tx1b
.vout
= [CTxOut(int(0.9*COIN
), CScript([b
'b']))]
147 tx1b_hex
= txToHex(tx1b
)
148 # Replacement still disabled even with "enough fee"
149 assert_raises_rpc_error(-26, "txn-mempool-conflict", self
.nodes
[1].sendrawtransaction
, tx1b_hex
, True)
151 tx1b_txid
= self
.nodes
[0].sendrawtransaction(tx1b_hex
, True)
153 mempool
= self
.nodes
[0].getrawmempool()
155 assert (tx1a_txid
not in mempool
)
156 assert (tx1b_txid
in mempool
)
158 assert_equal(tx1b_hex
, self
.nodes
[0].getrawtransaction(tx1b_txid
))
160 # Second node is running mempoolreplacement=0, will not replace originally-seen txn
161 mempool
= self
.nodes
[1].getrawmempool()
162 assert tx1a_txid
in mempool
163 assert tx1b_txid
not in mempool
165 def test_doublespend_chain(self
):
166 """Doublespend of a long chain"""
168 initial_nValue
= 50*COIN
169 tx0_outpoint
= make_utxo(self
.nodes
[0], initial_nValue
)
171 prevout
= tx0_outpoint
172 remaining_value
= initial_nValue
174 while remaining_value
> 10*COIN
:
175 remaining_value
-= 1*COIN
177 tx
.vin
= [CTxIn(prevout
, nSequence
=0)]
178 tx
.vout
= [CTxOut(remaining_value
, CScript([1]))]
180 txid
= self
.nodes
[0].sendrawtransaction(tx_hex
, True)
181 chain_txids
.append(txid
)
182 prevout
= COutPoint(int(txid
, 16), 0)
184 # Whether the double-spend is allowed is evaluated by including all
185 # child fees - 40 BTC - so this attempt is rejected.
186 dbl_tx
= CTransaction()
187 dbl_tx
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
188 dbl_tx
.vout
= [CTxOut(initial_nValue
- 30*COIN
, CScript([1]))]
189 dbl_tx_hex
= txToHex(dbl_tx
)
191 # This will raise an exception due to insufficient fee
192 assert_raises_rpc_error(-26, "insufficient fee", self
.nodes
[0].sendrawtransaction
, dbl_tx_hex
, True)
194 # Accepted with sufficient fee
195 dbl_tx
= CTransaction()
196 dbl_tx
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
197 dbl_tx
.vout
= [CTxOut(1*COIN
, CScript([1]))]
198 dbl_tx_hex
= txToHex(dbl_tx
)
199 self
.nodes
[0].sendrawtransaction(dbl_tx_hex
, True)
201 mempool
= self
.nodes
[0].getrawmempool()
202 for doublespent_txid
in chain_txids
:
203 assert(doublespent_txid
not in mempool
)
205 def test_doublespend_tree(self
):
206 """Doublespend of a big tree of transactions"""
208 initial_nValue
= 50*COIN
209 tx0_outpoint
= make_utxo(self
.nodes
[0], initial_nValue
)
211 def branch(prevout
, initial_value
, max_txs
, tree_width
=5, fee
=0.0001*COIN
, _total_txs
=None):
212 if _total_txs
is None:
214 if _total_txs
[0] >= max_txs
:
217 txout_value
= (initial_value
- fee
) // tree_width
218 if txout_value
< fee
:
221 vout
= [CTxOut(txout_value
, CScript([i
+1]))
222 for i
in range(tree_width
)]
224 tx
.vin
= [CTxIn(prevout
, nSequence
=0)]
228 assert(len(tx
.serialize()) < 100000)
229 txid
= self
.nodes
[0].sendrawtransaction(tx_hex
, True)
235 for i
, txout
in enumerate(tx
.vout
):
236 for x
in branch(COutPoint(txid
, i
), txout_value
,
238 tree_width
=tree_width
, fee
=fee
,
239 _total_txs
=_total_txs
):
242 fee
= int(0.0001*COIN
)
243 n
= MAX_REPLACEMENT_LIMIT
244 tree_txs
= list(branch(tx0_outpoint
, initial_nValue
, n
, fee
=fee
))
245 assert_equal(len(tree_txs
), n
)
247 # Attempt double-spend, will fail because too little fee paid
248 dbl_tx
= CTransaction()
249 dbl_tx
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
250 dbl_tx
.vout
= [CTxOut(initial_nValue
- fee
*n
, CScript([1]))]
251 dbl_tx_hex
= txToHex(dbl_tx
)
252 # This will raise an exception due to insufficient fee
253 assert_raises_rpc_error(-26, "insufficient fee", self
.nodes
[0].sendrawtransaction
, dbl_tx_hex
, True)
255 # 1 BTC fee is enough
256 dbl_tx
= CTransaction()
257 dbl_tx
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
258 dbl_tx
.vout
= [CTxOut(initial_nValue
- fee
*n
- 1*COIN
, CScript([1]))]
259 dbl_tx_hex
= txToHex(dbl_tx
)
260 self
.nodes
[0].sendrawtransaction(dbl_tx_hex
, True)
262 mempool
= self
.nodes
[0].getrawmempool()
266 assert (tx
.hash not in mempool
)
268 # Try again, but with more total transactions than the "max txs
269 # double-spent at once" anti-DoS limit.
270 for n
in (MAX_REPLACEMENT_LIMIT
+1, MAX_REPLACEMENT_LIMIT
*2):
271 fee
= int(0.0001*COIN
)
272 tx0_outpoint
= make_utxo(self
.nodes
[0], initial_nValue
)
273 tree_txs
= list(branch(tx0_outpoint
, initial_nValue
, n
, fee
=fee
))
274 assert_equal(len(tree_txs
), n
)
276 dbl_tx
= CTransaction()
277 dbl_tx
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
278 dbl_tx
.vout
= [CTxOut(initial_nValue
- 2*fee
*n
, CScript([1]))]
279 dbl_tx_hex
= txToHex(dbl_tx
)
280 # This will raise an exception
281 assert_raises_rpc_error(-26, "too many potential replacements", self
.nodes
[0].sendrawtransaction
, dbl_tx_hex
, True)
285 self
.nodes
[0].getrawtransaction(tx
.hash)
287 def test_replacement_feeperkb(self
):
288 """Replacement requires fee-per-KB to be higher"""
289 tx0_outpoint
= make_utxo(self
.nodes
[0], int(1.1*COIN
))
291 tx1a
= CTransaction()
292 tx1a
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
293 tx1a
.vout
= [CTxOut(1*COIN
, CScript([b
'a']))]
294 tx1a_hex
= txToHex(tx1a
)
295 self
.nodes
[0].sendrawtransaction(tx1a_hex
, True)
297 # Higher fee, but the fee per KB is much lower, so the replacement is
299 tx1b
= CTransaction()
300 tx1b
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
301 tx1b
.vout
= [CTxOut(int(0.001*COIN
), CScript([b
'a'*999000]))]
302 tx1b_hex
= txToHex(tx1b
)
304 # This will raise an exception due to insufficient fee
305 assert_raises_rpc_error(-26, "insufficient fee", self
.nodes
[0].sendrawtransaction
, tx1b_hex
, True)
307 def test_spends_of_conflicting_outputs(self
):
308 """Replacements that spend conflicting tx outputs are rejected"""
309 utxo1
= make_utxo(self
.nodes
[0], int(1.2*COIN
))
310 utxo2
= make_utxo(self
.nodes
[0], 3*COIN
)
312 tx1a
= CTransaction()
313 tx1a
.vin
= [CTxIn(utxo1
, nSequence
=0)]
314 tx1a
.vout
= [CTxOut(int(1.1*COIN
), CScript([b
'a']))]
315 tx1a_hex
= txToHex(tx1a
)
316 tx1a_txid
= self
.nodes
[0].sendrawtransaction(tx1a_hex
, True)
318 tx1a_txid
= int(tx1a_txid
, 16)
320 # Direct spend an output of the transaction we're replacing.
322 tx2
.vin
= [CTxIn(utxo1
, nSequence
=0), CTxIn(utxo2
, nSequence
=0)]
323 tx2
.vin
.append(CTxIn(COutPoint(tx1a_txid
, 0), nSequence
=0))
325 tx2_hex
= txToHex(tx2
)
327 # This will raise an exception
328 assert_raises_rpc_error(-26, "bad-txns-spends-conflicting-tx", self
.nodes
[0].sendrawtransaction
, tx2_hex
, True)
330 # Spend tx1a's output to test the indirect case.
331 tx1b
= CTransaction()
332 tx1b
.vin
= [CTxIn(COutPoint(tx1a_txid
, 0), nSequence
=0)]
333 tx1b
.vout
= [CTxOut(1*COIN
, CScript([b
'a']))]
334 tx1b_hex
= txToHex(tx1b
)
335 tx1b_txid
= self
.nodes
[0].sendrawtransaction(tx1b_hex
, True)
336 tx1b_txid
= int(tx1b_txid
, 16)
339 tx2
.vin
= [CTxIn(utxo1
, nSequence
=0), CTxIn(utxo2
, nSequence
=0),
340 CTxIn(COutPoint(tx1b_txid
, 0))]
342 tx2_hex
= txToHex(tx2
)
344 # This will raise an exception
345 assert_raises_rpc_error(-26, "bad-txns-spends-conflicting-tx", self
.nodes
[0].sendrawtransaction
, tx2_hex
, True)
347 def test_new_unconfirmed_inputs(self
):
348 """Replacements that add new unconfirmed inputs are rejected"""
349 confirmed_utxo
= make_utxo(self
.nodes
[0], int(1.1*COIN
))
350 unconfirmed_utxo
= make_utxo(self
.nodes
[0], int(0.1*COIN
), False)
353 tx1
.vin
= [CTxIn(confirmed_utxo
)]
354 tx1
.vout
= [CTxOut(1*COIN
, CScript([b
'a']))]
355 tx1_hex
= txToHex(tx1
)
356 self
.nodes
[0].sendrawtransaction(tx1_hex
, True)
359 tx2
.vin
= [CTxIn(confirmed_utxo
), CTxIn(unconfirmed_utxo
)]
361 tx2_hex
= txToHex(tx2
)
363 # This will raise an exception
364 assert_raises_rpc_error(-26, "replacement-adds-unconfirmed", self
.nodes
[0].sendrawtransaction
, tx2_hex
, True)
366 def test_too_many_replacements(self
):
367 """Replacements that evict too many transactions are rejected"""
368 # Try directly replacing more than MAX_REPLACEMENT_LIMIT
371 # Start by creating a single transaction with many outputs
372 initial_nValue
= 10*COIN
373 utxo
= make_utxo(self
.nodes
[0], initial_nValue
)
374 fee
= int(0.0001*COIN
)
375 split_value
= int((initial_nValue
-fee
)/(MAX_REPLACEMENT_LIMIT
+1))
378 for i
in range(MAX_REPLACEMENT_LIMIT
+1):
379 outputs
.append(CTxOut(split_value
, CScript([1])))
381 splitting_tx
= CTransaction()
382 splitting_tx
.vin
= [CTxIn(utxo
, nSequence
=0)]
383 splitting_tx
.vout
= outputs
384 splitting_tx_hex
= txToHex(splitting_tx
)
386 txid
= self
.nodes
[0].sendrawtransaction(splitting_tx_hex
, True)
389 # Now spend each of those outputs individually
390 for i
in range(MAX_REPLACEMENT_LIMIT
+1):
391 tx_i
= CTransaction()
392 tx_i
.vin
= [CTxIn(COutPoint(txid
, i
), nSequence
=0)]
393 tx_i
.vout
= [CTxOut(split_value
-fee
, CScript([b
'a']))]
394 tx_i_hex
= txToHex(tx_i
)
395 self
.nodes
[0].sendrawtransaction(tx_i_hex
, True)
397 # Now create doublespend of the whole lot; should fail.
398 # Need a big enough fee to cover all spending transactions and have
400 double_spend_value
= (split_value
-100*fee
)*(MAX_REPLACEMENT_LIMIT
+1)
402 for i
in range(MAX_REPLACEMENT_LIMIT
+1):
403 inputs
.append(CTxIn(COutPoint(txid
, i
), nSequence
=0))
404 double_tx
= CTransaction()
405 double_tx
.vin
= inputs
406 double_tx
.vout
= [CTxOut(double_spend_value
, CScript([b
'a']))]
407 double_tx_hex
= txToHex(double_tx
)
409 # This will raise an exception
410 assert_raises_rpc_error(-26, "too many potential replacements", self
.nodes
[0].sendrawtransaction
, double_tx_hex
, True)
412 # If we remove an input, it should pass
413 double_tx
= CTransaction()
414 double_tx
.vin
= inputs
[0:-1]
415 double_tx
.vout
= [CTxOut(double_spend_value
, CScript([b
'a']))]
416 double_tx_hex
= txToHex(double_tx
)
417 self
.nodes
[0].sendrawtransaction(double_tx_hex
, True)
419 def test_opt_in(self
):
420 """Replacing should only work if orig tx opted in"""
421 tx0_outpoint
= make_utxo(self
.nodes
[0], int(1.1*COIN
))
423 # Create a non-opting in transaction
424 tx1a
= CTransaction()
425 tx1a
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0xffffffff)]
426 tx1a
.vout
= [CTxOut(1*COIN
, CScript([b
'a']))]
427 tx1a_hex
= txToHex(tx1a
)
428 tx1a_txid
= self
.nodes
[0].sendrawtransaction(tx1a_hex
, True)
430 # Shouldn't be able to double-spend
431 tx1b
= CTransaction()
432 tx1b
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
433 tx1b
.vout
= [CTxOut(int(0.9*COIN
), CScript([b
'b']))]
434 tx1b_hex
= txToHex(tx1b
)
436 # This will raise an exception
437 assert_raises_rpc_error(-26, "txn-mempool-conflict", self
.nodes
[0].sendrawtransaction
, tx1b_hex
, True)
439 tx1_outpoint
= make_utxo(self
.nodes
[0], int(1.1*COIN
))
441 # Create a different non-opting in transaction
442 tx2a
= CTransaction()
443 tx2a
.vin
= [CTxIn(tx1_outpoint
, nSequence
=0xfffffffe)]
444 tx2a
.vout
= [CTxOut(1*COIN
, CScript([b
'a']))]
445 tx2a_hex
= txToHex(tx2a
)
446 tx2a_txid
= self
.nodes
[0].sendrawtransaction(tx2a_hex
, True)
448 # Still shouldn't be able to double-spend
449 tx2b
= CTransaction()
450 tx2b
.vin
= [CTxIn(tx1_outpoint
, nSequence
=0)]
451 tx2b
.vout
= [CTxOut(int(0.9*COIN
), CScript([b
'b']))]
452 tx2b_hex
= txToHex(tx2b
)
454 # This will raise an exception
455 assert_raises_rpc_error(-26, "txn-mempool-conflict", self
.nodes
[0].sendrawtransaction
, tx2b_hex
, True)
457 # Now create a new transaction that spends from tx1a and tx2a
458 # opt-in on one of the inputs
459 # Transaction should be replaceable on either input
461 tx1a_txid
= int(tx1a_txid
, 16)
462 tx2a_txid
= int(tx2a_txid
, 16)
464 tx3a
= CTransaction()
465 tx3a
.vin
= [CTxIn(COutPoint(tx1a_txid
, 0), nSequence
=0xffffffff),
466 CTxIn(COutPoint(tx2a_txid
, 0), nSequence
=0xfffffffd)]
467 tx3a
.vout
= [CTxOut(int(0.9*COIN
), CScript([b
'c'])), CTxOut(int(0.9*COIN
), CScript([b
'd']))]
468 tx3a_hex
= txToHex(tx3a
)
470 self
.nodes
[0].sendrawtransaction(tx3a_hex
, True)
472 tx3b
= CTransaction()
473 tx3b
.vin
= [CTxIn(COutPoint(tx1a_txid
, 0), nSequence
=0)]
474 tx3b
.vout
= [CTxOut(int(0.5*COIN
), CScript([b
'e']))]
475 tx3b_hex
= txToHex(tx3b
)
477 tx3c
= CTransaction()
478 tx3c
.vin
= [CTxIn(COutPoint(tx2a_txid
, 0), nSequence
=0)]
479 tx3c
.vout
= [CTxOut(int(0.5*COIN
), CScript([b
'f']))]
480 tx3c_hex
= txToHex(tx3c
)
482 self
.nodes
[0].sendrawtransaction(tx3b_hex
, True)
483 # If tx3b was accepted, tx3c won't look like a replacement,
484 # but make sure it is accepted anyway
485 self
.nodes
[0].sendrawtransaction(tx3c_hex
, True)
487 def test_prioritised_transactions(self
):
488 # Ensure that fee deltas used via prioritisetransaction are
489 # correctly used by replacement logic
491 # 1. Check that feeperkb uses modified fees
492 tx0_outpoint
= make_utxo(self
.nodes
[0], int(1.1*COIN
))
494 tx1a
= CTransaction()
495 tx1a
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
496 tx1a
.vout
= [CTxOut(1*COIN
, CScript([b
'a']))]
497 tx1a_hex
= txToHex(tx1a
)
498 tx1a_txid
= self
.nodes
[0].sendrawtransaction(tx1a_hex
, True)
500 # Higher fee, but the actual fee per KB is much lower.
501 tx1b
= CTransaction()
502 tx1b
.vin
= [CTxIn(tx0_outpoint
, nSequence
=0)]
503 tx1b
.vout
= [CTxOut(int(0.001*COIN
), CScript([b
'a'*740000]))]
504 tx1b_hex
= txToHex(tx1b
)
506 # Verify tx1b cannot replace tx1a.
507 assert_raises_rpc_error(-26, "insufficient fee", self
.nodes
[0].sendrawtransaction
, tx1b_hex
, True)
509 # Use prioritisetransaction to set tx1a's fee to 0.
510 self
.nodes
[0].prioritisetransaction(txid
=tx1a_txid
, fee_delta
=int(-0.1*COIN
))
512 # Now tx1b should be able to replace tx1a
513 tx1b_txid
= self
.nodes
[0].sendrawtransaction(tx1b_hex
, True)
515 assert(tx1b_txid
in self
.nodes
[0].getrawmempool())
517 # 2. Check that absolute fee checks use modified fee.
518 tx1_outpoint
= make_utxo(self
.nodes
[0], int(1.1*COIN
))
520 tx2a
= CTransaction()
521 tx2a
.vin
= [CTxIn(tx1_outpoint
, nSequence
=0)]
522 tx2a
.vout
= [CTxOut(1*COIN
, CScript([b
'a']))]
523 tx2a_hex
= txToHex(tx2a
)
524 self
.nodes
[0].sendrawtransaction(tx2a_hex
, True)
526 # Lower fee, but we'll prioritise it
527 tx2b
= CTransaction()
528 tx2b
.vin
= [CTxIn(tx1_outpoint
, nSequence
=0)]
529 tx2b
.vout
= [CTxOut(int(1.01*COIN
), CScript([b
'a']))]
531 tx2b_hex
= txToHex(tx2b
)
533 # Verify tx2b cannot replace tx2a.
534 assert_raises_rpc_error(-26, "insufficient fee", self
.nodes
[0].sendrawtransaction
, tx2b_hex
, True)
536 # Now prioritise tx2b to have a higher modified fee
537 self
.nodes
[0].prioritisetransaction(txid
=tx2b
.hash, fee_delta
=int(0.1*COIN
))
539 # tx2b should now be accepted
540 tx2b_txid
= self
.nodes
[0].sendrawtransaction(tx2b_hex
, True)
542 assert(tx2b_txid
in self
.nodes
[0].getrawmempool())
545 us0
= self
.nodes
[0].listunspent()[0]
547 outs
= {self
.nodes
[0].getnewaddress() : Decimal(1.0000000)}
548 rawtx0
= self
.nodes
[0].createrawtransaction(ins
, outs
, 0, True)
549 rawtx1
= self
.nodes
[0].createrawtransaction(ins
, outs
, 0, False)
550 json0
= self
.nodes
[0].decoderawtransaction(rawtx0
)
551 json1
= self
.nodes
[0].decoderawtransaction(rawtx1
)
552 assert_equal(json0
["vin"][0]["sequence"], 4294967293)
553 assert_equal(json1
["vin"][0]["sequence"], 4294967295)
555 rawtx2
= self
.nodes
[0].createrawtransaction([], outs
)
556 frawtx2a
= self
.nodes
[0].fundrawtransaction(rawtx2
, {"replaceable": True})
557 frawtx2b
= self
.nodes
[0].fundrawtransaction(rawtx2
, {"replaceable": False})
559 json0
= self
.nodes
[0].decoderawtransaction(frawtx2a
['hex'])
560 json1
= self
.nodes
[0].decoderawtransaction(frawtx2b
['hex'])
561 assert_equal(json0
["vin"][0]["sequence"], 4294967293)
562 assert_equal(json1
["vin"][0]["sequence"], 4294967294)
564 if __name__
== '__main__':
565 ReplaceByFeeTest().main()