mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 20:35:13 +00:00
sort coins by age in get_unspent_coins()
This commit is contained in:
parent
36011fbaa4
commit
428fbf1f63
1 changed files with 10 additions and 2 deletions
|
@ -948,8 +948,16 @@ class Wallet:
|
|||
key = tx_hash + ":%d" % output.get('index')
|
||||
if key in self.spent_outputs: continue
|
||||
output['tx_hash'] = tx_hash
|
||||
coins.append(output)
|
||||
return coins
|
||||
output['height'] = tx_height
|
||||
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]
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue