aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtest/functional/feature_bip68_sequence.py6
-rw-r--r--test/functional/test_framework/wallet.py20
2 files changed, 16 insertions, 10 deletions
diff --git a/test/functional/feature_bip68_sequence.py b/test/functional/feature_bip68_sequence.py
index 894afffc79..8768d4040d 100755
--- a/test/functional/feature_bip68_sequence.py
+++ b/test/functional/feature_bip68_sequence.py
@@ -408,10 +408,8 @@ class BIP68Test(BitcoinTestFramework):
# Use self.nodes[1] to test that version 2 transactions are standard.
def test_version2_relay(self):
mini_wallet = MiniWallet(self.nodes[1])
- mini_wallet.rescan_utxos()
- tx = mini_wallet.create_self_transfer()["tx"]
- tx.nVersion = 2
- mini_wallet.sendrawtransaction(from_node=self.nodes[1], tx_hex=tx.serialize().hex())
+ mini_wallet.send_self_transfer(from_node=self.nodes[1], version=2)
+
if __name__ == '__main__':
BIP68Test().main()
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index 53c8e1b0cc..470ed08ed4 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -286,11 +286,12 @@ class MiniWallet:
utxos_to_spend: Optional[list[dict]] = None,
num_outputs=1,
amount_per_output=0,
+ version=2,
locktime=0,
sequence=0,
fee_per_output=1000,
target_weight=0,
- confirmed_only=False
+ confirmed_only=False,
):
"""
Create and return a transaction that spends the given UTXOs and creates a
@@ -313,6 +314,7 @@ class MiniWallet:
tx = CTransaction()
tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']), nSequence=seq) for utxo_to_spend, seq in zip(utxos_to_spend, sequence)]
tx.vout = [CTxOut(amount_per_output, bytearray(self._scriptPubKey)) for _ in range(num_outputs)]
+ tx.nVersion = version
tx.nLockTime = locktime
self.sign_tx(tx)
@@ -337,14 +339,15 @@ class MiniWallet:
"tx": tx,
}
- def create_self_transfer(self, *,
+ def create_self_transfer(
+ self,
+ *,
fee_rate=Decimal("0.003"),
fee=Decimal("0"),
utxo_to_spend=None,
- locktime=0,
- sequence=0,
target_weight=0,
- confirmed_only=False
+ confirmed_only=False,
+ **kwargs,
):
"""Create and return a tx with the specified fee. If fee is 0, use fee_rate, where the resulting fee may be exact or at most one satoshi higher than needed."""
utxo_to_spend = utxo_to_spend or self.get_utxo(confirmed_only=confirmed_only)
@@ -360,7 +363,12 @@ class MiniWallet:
send_value = utxo_to_spend["value"] - (fee or (fee_rate * vsize / 1000))
# create tx
- tx = self.create_self_transfer_multi(utxos_to_spend=[utxo_to_spend], locktime=locktime, sequence=sequence, amount_per_output=int(COIN * send_value), target_weight=target_weight)
+ tx = self.create_self_transfer_multi(
+ utxos_to_spend=[utxo_to_spend],
+ amount_per_output=int(COIN * send_value),
+ target_weight=target_weight,
+ **kwargs,
+ )
if not target_weight:
assert_equal(tx["tx"].get_vsize(), vsize)
tx["new_utxo"] = tx.pop("new_utxos")[0]