git://git.novaco.in
/
electrum-nvc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
(parent:
36011fb
)
sort coins by age in get_unspent_coins()
author
ThomasV
<thomasv@gitorious>
Sun, 15 Sep 2013 21:37:40 +0000 (23:37 +0200)
committer
ThomasV
<thomasv@gitorious>
Sun, 15 Sep 2013 21:37:40 +0000 (23:37 +0200)
lib/wallet.py
patch
|
blob
|
history
diff --git
a/lib/wallet.py
b/lib/wallet.py
index
bff386a
..
cfd9bc6
100644
(file)
--- a/
lib/wallet.py
+++ b/
lib/wallet.py
@@
-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]