Skip to content

Commit 144228b

Browse files
committed
merge bitcoin#25356: Remove MiniWallet mempool_valid option
1 parent 0622788 commit 144228b

File tree

5 files changed

+10
-16
lines changed

5 files changed

+10
-16
lines changed

test/functional/mempool_limit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def set_test_params(self):
3131

3232
def send_large_txs(self, node, miniwallet, txouts, fee, tx_batch_size):
3333
for _ in range(tx_batch_size):
34-
tx = miniwallet.create_self_transfer(from_node=node, fee_rate=0, mempool_valid=False)['tx']
34+
tx = miniwallet.create_self_transfer(from_node=node, fee_rate=0)['tx']
3535
for txout in txouts:
3636
tx.vout.append(txout)
3737
tx.vout[0].nValue -= int(fee * COIN)
@@ -85,7 +85,7 @@ def run_test(self):
8585

8686
# Deliberately try to create a tx with a fee less than the minimum mempool fee to assert that it does not get added to the mempool
8787
self.log.info('Create a mempool tx that will not pass mempoolminfee')
88-
assert_raises_rpc_error(-26, "mempool min fee not met", miniwallet.send_self_transfer, from_node=node, fee_rate=relayfee, mempool_valid=False)
88+
assert_raises_rpc_error(-26, "mempool min fee not met", miniwallet.send_self_transfer, from_node=node, fee_rate=relayfee)
8989

9090
self.log.info('Test passing a value below the minimum (5 MB) to -maxmempool throws an error')
9191
self.stop_node(0)

test/functional/mempool_reorg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def run_test(self):
5353
utxo = wallet.get_utxo(txid=coinbase_txids[0])
5454
timelock_tx = wallet.create_self_transfer(
5555
utxo_to_spend=utxo,
56-
mempool_valid=False,
57-
locktime=self.nodes[0].getblockcount() + 2
56+
locktime=self.nodes[0].getblockcount() + 2,
5857
)['hex']
5958

6059
self.log.info("Check that the time-locked transaction is too immature to spend")

test/functional/mempool_spend_coinbase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def run_test(self):
4040
spend_mature_id = wallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=utxo_mature)["txid"]
4141

4242
# other coinbase should be too immature to spend
43-
immature_tx = wallet.create_self_transfer(utxo_to_spend=utxo_immature, mempool_valid=False)
43+
immature_tx = wallet.create_self_transfer(utxo_to_spend=utxo_immature)
4444
assert_raises_rpc_error(-26,
4545
"bad-txns-premature-spend-of-coinbase",
4646
lambda: self.nodes[0].sendrawtransaction(immature_tx['hex']))

test/functional/test_framework/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ def mine_large_block(test_framework, mini_wallet, node):
642642
from .messages import COIN
643643
fee = 100 * int(node.getnetworkinfo()["relayfee"] * COIN)
644644
for _ in range(14):
645-
tx = mini_wallet.create_self_transfer(from_node=node, fee_rate=0, mempool_valid=False)['tx']
645+
tx = mini_wallet.create_self_transfer(from_node=node, fee_rate=0)['tx']
646646
tx.vout[0].nValue -= fee
647647
tx.vout.extend(txouts)
648648
mini_wallet.sendrawtransaction(from_node=node, tx_hex=tx.serialize().hex())

test/functional/test_framework/wallet.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def send_to(self, *, from_node, scriptPubKey, amount, fee=1000):
187187
188188
Returns a tuple (txid, n) referring to the created external utxo outpoint.
189189
"""
190-
tx = self.create_self_transfer(from_node=from_node, fee_rate=0, mempool_valid=False)['tx']
190+
tx = self.create_self_transfer(from_node=from_node, fee_rate=0)["tx"]
191191
assert_greater_than_or_equal(tx.vout[0].nValue, amount + fee)
192192
tx.vout[0].nValue -= (amount + fee) # change output -> MiniWallet
193193
tx.vout.append(CTxOut(amount, scriptPubKey)) # arbitrary output -> to be returned
@@ -224,7 +224,7 @@ def create_self_transfer_multi(
224224
# create simple tx template (1 input, 1 output)
225225
tx = self.create_self_transfer(
226226
fee_rate=0, from_node=from_node,
227-
utxo_to_spend=utxos_to_spend[0], sequence=sequence, mempool_valid=False)['tx']
227+
utxo_to_spend=utxos_to_spend[0], sequence=sequence)["tx"]
228228

229229
# duplicate inputs, witnesses and outputs
230230
tx.vin = [deepcopy(tx.vin[0]) for _ in range(len(utxos_to_spend))]
@@ -241,9 +241,8 @@ def create_self_transfer_multi(
241241
o.nValue = outputs_value_total // num_outputs
242242
return tx
243243

244-
def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, utxo_to_spend=None, mempool_valid=True, locktime=0, sequence=0):
245-
"""Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed.
246-
Checking mempool validity via the testmempoolaccept RPC can be skipped by setting mempool_valid to False."""
244+
def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, utxo_to_spend=None, locktime=0, sequence=0):
245+
"""Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
247246
from_node = from_node or self._test_node
248247
utxo_to_spend = utxo_to_spend or self.get_utxo()
249248
if self._mode in (MiniWalletMode.RAW_OP_TRUE, MiniWalletMode.ADDRESS_OP_TRUE):
@@ -269,11 +268,7 @@ def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, utx
269268
assert False
270269
tx_hex = tx.serialize().hex()
271270

272-
if mempool_valid:
273-
tx_info = from_node.testmempoolaccept([tx_hex])[0]
274-
assert_equal(tx_info['allowed'], True)
275-
assert_equal(len(tx_hex) // 2, vsize) # 1 byte = 2 character
276-
assert_equal(tx_info['fees']['base'], utxo_to_spend['value'] - Decimal(send_value) / COIN)
271+
assert_equal(tx.get_vsize(), vsize)
277272

278273
return {'txid': tx.rehash(), 'hex': tx_hex, 'tx': tx}
279274

0 commit comments

Comments
 (0)