Skip to content

Commit

Permalink
Returning sum of amount selected in select_inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaenigma committed Feb 3, 2016
1 parent 9c32f4e commit e336c87
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion moneywagon/tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def select_inputs(self, amount):
'''Maximize transaction priority. Select the oldest inputs,
that are sufficient to cover the spent amount. Then,
remove any unneeded inputs, starting with
the smallest in value.'''
the smallest in value.
Returns sum of amounts of inputs selected'''
sorted_txin = sorted(self.ins, key=lambda x:-x['input']['confirmations'])
total_amount = 0
for (idx, tx_in) in enumerate(sorted_txin):
Expand All @@ -135,6 +136,7 @@ def select_inputs(self, amount):
else:
total_amount -= value
self.ins = sorted_txin[idx:]
return total_amount

def add_output(self, address, value, unit='satoshi'):
"""
Expand Down

0 comments on commit e336c87

Please sign in to comment.