Skip to content

Conversation

@lukavada
Copy link

bit/bit/transaction.py

Lines 316 to 329 in d351d1d

while unspents:
selected_coins.append(unspents.pop(0))
estimated_fee = estimate_tx_fee(
sum(u.vsize for u in selected_coins), len(selected_coins), sum(output_size), len(output_size), fee, any(u.segwit for u in selected_coins)
)
estimated_fee = fee if absolute_fee else estimated_fee
remaining = sum(u.amount for u in selected_coins) - target - estimated_fee
if remaining >= min_change and (not consolidate or len(unspents) == 0):
break
else:
raise InsufficientFunds(
'Balance {} is less than {} (including '
'fee).'.format(sum(u.amount for u in selected_coins), target + min_change + estimated_fee)
)

estimated_fee integer is initialized within the while block of select_coins, resulting in UnboundLocalError in the case when an empty container is provided for the unspents argument.

from bit.transaction import select_coins

# Should raise InsufficientFunds
s = select_coins(10000, 1, [42], 100, unspents=[])

UnboundLocalError: cannot access local variable 'estimated_fee' where it is not associated with a value

The PR proposes to initialize the estimated_fee integer right before the while condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant