0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-03 09:56:38 -05:00

test: bugfix: Actually pick largest utxo

This commit is contained in:
MarcoFalke 2020-09-09 10:07:05 +02:00
parent 564e1ab0f3
commit fa65a11d0c
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -42,12 +42,12 @@ class MiniWallet:
def send_self_transfer(self, *, fee_rate, from_node): def send_self_transfer(self, *, fee_rate, from_node):
"""Create and send a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed.""" """Create and send 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']) self._utxos = sorted(self._utxos, key=lambda k: k['value'])
largest_utxo = self._utxos.pop() # Pick the largest utxo and hope it covers the fee largest_utxo = self._utxos.pop() # Pick the largest utxo and hope it covers the fee
vsize = Decimal(96) vsize = Decimal(96)
send_value = satoshi_round(largest_utxo['value'] - fee_rate * (vsize / 1000)) send_value = satoshi_round(largest_utxo['value'] - fee_rate * (vsize / 1000))
fee = largest_utxo['value'] - send_value fee = largest_utxo['value'] - send_value
assert (send_value > 0) assert send_value > 0
tx = CTransaction() tx = CTransaction()
tx.vin = [CTxIn(COutPoint(int(largest_utxo['txid'], 16), largest_utxo['vout']))] tx.vin = [CTxIn(COutPoint(int(largest_utxo['txid'], 16), largest_utxo['vout']))]