aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/wallet.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-05-27 20:15:02 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-06-08 19:38:43 +0200
commitd6d2ab984547be4a9f7ba859a2a4c9ac9bfbf206 (patch)
treebb8431b7c3ddbe1757526f4e9269cae01137ef84 /test/functional/test_framework/wallet.py
parentce024b1c0ef2dcd307023aaaab40373c8bf17db1 (diff)
test: MiniWallet: fix fee calculation for P2PK and check tx vsize
Diffstat (limited to 'test/functional/test_framework/wallet.py')
-rw-r--r--test/functional/test_framework/wallet.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index 4b761128ee..19628c0791 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -142,7 +142,10 @@ class MiniWallet:
"""Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
self._utxos = sorted(self._utxos, key=lambda k: k['value'])
utxo_to_spend = utxo_to_spend or self._utxos.pop() # Pick the largest utxo (if none provided) and hope it covers the fee
- vsize = Decimal(96)
+ if self._priv_key is None:
+ vsize = Decimal(96) # anyone-can-spend
+ else:
+ vsize = Decimal(168) # P2PK (73 bytes scriptSig + 35 bytes scriptPubKey + 60 bytes other)
send_value = satoshi_round(utxo_to_spend['value'] - fee_rate * (vsize / 1000))
fee = utxo_to_spend['value'] - send_value
assert send_value > 0
@@ -167,10 +170,7 @@ class MiniWallet:
tx_info = from_node.testmempoolaccept([tx_hex])[0]
assert_equal(mempool_valid, tx_info['allowed'])
if mempool_valid:
- # TODO: for P2PK, vsize is not constant due to varying scriptSig length,
- # so only check this for anyone-can-spend outputs right now
- if self._priv_key is None:
- assert_equal(tx_info['vsize'], vsize)
+ assert_equal(tx_info['vsize'], vsize)
assert_equal(tx_info['fees']['base'], fee)
return {'txid': tx_info['txid'], 'wtxid': tx_info['wtxid'], 'hex': tx_hex, 'tx': tx}