sort coins by age in get_unspent_coins()
This commit is contained in:
@@ -948,8 +948,16 @@ class Wallet:
|
|||||||
key = tx_hash + ":%d" % output.get('index')
|
key = tx_hash + ":%d" % output.get('index')
|
||||||
if key in self.spent_outputs: continue
|
if key in self.spent_outputs: continue
|
||||||
output['tx_hash'] = tx_hash
|
output['tx_hash'] = tx_hash
|
||||||
coins.append(output)
|
output['height'] = tx_height
|
||||||
return coins
|
coins.append((tx_height, output))
|
||||||
|
|
||||||
|
# sort by age
|
||||||
|
if coins:
|
||||||
|
coins = sorted(coins)
|
||||||
|
if coins[-1][0] != 0:
|
||||||
|
while coins[0][0] == 0:
|
||||||
|
coins = coins[1:] + [ coins[0] ]
|
||||||
|
return [x[1] for x in coins]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user