Skip to content

Commit

Permalink
test: bugfix: Actually pick largest utxo
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Sep 9, 2020
1 parent 564e1ab commit fa65a11
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/functional/test_framework/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def generate(self, num_blocks):

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."""
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
vsize = Decimal(96)
send_value = satoshi_round(largest_utxo['value'] - fee_rate * (vsize / 1000))
fee = largest_utxo['value'] - send_value
assert (send_value > 0)
assert send_value > 0

tx = CTransaction()
tx.vin = [CTxIn(COutPoint(int(largest_utxo['txid'], 16), largest_utxo['vout']))]
Expand Down

0 comments on commit fa65a11

Please sign in to comment.