Skip to content

Commit ebfb239

Browse files
committed
merge bitcoin#25435: Remove from_node from create_self_transfer* MiniWallet helpers
1 parent 144228b commit ebfb239

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

test/functional/mempool_limit.py

Lines changed: 1 addition & 1 deletion
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)['tx']
34+
tx = miniwallet.create_self_transfer(fee_rate=0)['tx']
3535
for txout in txouts:
3636
tx.vout.append(txout)
3737
tx.vout[0].nValue -= int(fee * COIN)

test/functional/mempool_unbroadcast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_broadcast(self):
4040
wallet_tx_hsh = node.sendtoaddress(addr, 0.0001)
4141

4242
# generate a txn using sendrawtransaction
43-
txFS = self.wallet.create_self_transfer(from_node=node)
43+
txFS = self.wallet.create_self_transfer()
4444
rpc_tx_hsh = node.sendrawtransaction(txFS["hex"])
4545

4646
# check transactions are in unbroadcast using rpc

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)['tx']
645+
tx = mini_wallet.create_self_transfer(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: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ def get_utxo(self, *, txid: str = '', vout: Optional[int] = None, mark_as_spent=
169169
else:
170170
return self._utxos[index]
171171

172-
def send_self_transfer(self, **kwargs):
172+
def send_self_transfer(self, *, from_node, **kwargs):
173173
"""Create and send a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
174174
tx = self.create_self_transfer(**kwargs)
175-
self.sendrawtransaction(from_node=kwargs['from_node'], tx_hex=tx['hex'])
175+
self.sendrawtransaction(from_node=from_node, tx_hex=tx['hex'])
176176
return tx
177177

178178
def send_to(self, *, from_node, scriptPubKey, amount, fee=1000):
@@ -187,14 +187,14 @@ 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)["tx"]
190+
tx = self.create_self_transfer(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
194194
txid = self.sendrawtransaction(from_node=from_node, tx_hex=tx.serialize().hex())
195195
return txid, 1
196196

197-
def send_self_transfer_multi(self, **kwargs):
197+
def send_self_transfer_multi(self, *, from_node, **kwargs):
198198
"""
199199
Create and send a transaction that spends the given UTXOs and creates a
200200
certain number of outputs with equal amounts.
@@ -206,24 +206,26 @@ def send_self_transfer_multi(self, **kwargs):
206206
- list of newly created UTXOs, ordered by vout index
207207
"""
208208
tx = self.create_self_transfer_multi(**kwargs)
209-
txid = self.sendrawtransaction(from_node=kwargs['from_node'], tx_hex=tx.serialize().hex())
209+
txid = self.sendrawtransaction(from_node=from_node, tx_hex=tx.serialize().hex())
210210
return {'new_utxos': [self.get_utxo(txid=txid, vout=vout) for vout in range(len(tx.vout))],
211211
'txid': txid, 'hex': tx.serialize().hex(), 'tx': tx}
212212

213213
def create_self_transfer_multi(
214-
self, *, from_node,
215-
utxos_to_spend: Optional[List[dict]] = None,
216-
num_outputs=1,
217-
sequence=0,
218-
fee_per_output=1000):
214+
self,
215+
*,
216+
utxos_to_spend: Optional[List[dict]] = None,
217+
num_outputs=1,
218+
sequence=0,
219+
fee_per_output=1000,
220+
):
219221
"""
220222
Create and return a transaction that spends the given UTXOs and creates a
221223
certain number of outputs with equal amounts.
222224
"""
223225
utxos_to_spend = utxos_to_spend or [self.get_utxo()]
224226
# create simple tx template (1 input, 1 output)
225227
tx = self.create_self_transfer(
226-
fee_rate=0, from_node=from_node,
228+
fee_rate=0,
227229
utxo_to_spend=utxos_to_spend[0], sequence=sequence)["tx"]
228230

229231
# duplicate inputs, witnesses and outputs
@@ -241,9 +243,8 @@ def create_self_transfer_multi(
241243
o.nValue = outputs_value_total // num_outputs
242244
return tx
243245

244-
def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, utxo_to_spend=None, locktime=0, sequence=0):
246+
def create_self_transfer(self, *, fee_rate=Decimal("0.003"), utxo_to_spend=None, locktime=0, sequence=0):
245247
"""Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
246-
from_node = from_node or self._test_node
247248
utxo_to_spend = utxo_to_spend or self.get_utxo()
248249
if self._mode in (MiniWalletMode.RAW_OP_TRUE, MiniWalletMode.ADDRESS_OP_TRUE):
249250
vsize = Decimal(85) # anyone-can-spend

0 commit comments

Comments
 (0)