Skip to content

Commit 6120e8e

Browse files
committed
test: allow passing sequence through create_self_transfer_multi
And some little type annotation additions.
1 parent c5e67be commit 6120e8e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/functional/test_framework/wallet.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from random import choice
1111
from typing import (
1212
Any,
13+
List,
1314
Optional,
1415
)
1516
from test_framework.address import (
@@ -147,7 +148,7 @@ def get_descriptor(self):
147148
def get_address(self):
148149
return self._address
149150

150-
def get_utxo(self, *, txid: str = '', vout: Optional[int] = None, mark_as_spent=True):
151+
def get_utxo(self, *, txid: str = '', vout: Optional[int] = None, mark_as_spent=True) -> dict:
151152
"""
152153
Returns a utxo and marks it as spent (pops it from the internal list)
153154
@@ -208,14 +209,21 @@ def send_self_transfer_multi(self, **kwargs):
208209
return {'new_utxos': [self.get_utxo(txid=txid, vout=vout) for vout in range(len(tx.vout))],
209210
'txid': txid, 'hex': tx.serialize().hex(), 'tx': tx}
210211

211-
def create_self_transfer_multi(self, *, from_node, utxos_to_spend=None, num_outputs=1, fee_per_output=1000):
212+
def create_self_transfer_multi(
213+
self, *, from_node,
214+
utxos_to_spend: Optional[List[dict]] = None,
215+
num_outputs=1,
216+
sequence=0,
217+
fee_per_output=1000):
212218
"""
213219
Create and return a transaction that spends the given UTXOs and creates a
214220
certain number of outputs with equal amounts.
215221
"""
216222
utxos_to_spend = utxos_to_spend or [self.get_utxo()]
217223
# create simple tx template (1 input, 1 output)
218-
tx = self.create_self_transfer(fee_rate=0, from_node=from_node, utxo_to_spend=utxos_to_spend[0], mempool_valid=False)['tx']
224+
tx = self.create_self_transfer(
225+
fee_rate=0, from_node=from_node,
226+
utxo_to_spend=utxos_to_spend[0], sequence=sequence, mempool_valid=False)['tx']
219227

220228
# duplicate inputs, witnesses and outputs
221229
tx.vin = [deepcopy(tx.vin[0]) for _ in range(len(utxos_to_spend))]

0 commit comments

Comments
 (0)