URI: 
       tcheck coinbase maturity (fix #252) - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit ca75d3c08a2dd358967eacbacbfbb89ac3d504f9
   DIR parent 71c9f1d55521209ae03b33c21d9a7510254e1ce3
  HTML Author: thomasv <thomasv@gitorious>
       Date:   Mon,  7 Oct 2013 19:24:06 +0200
       
       check coinbase maturity (fix #252)
       
       Diffstat:
         M lib/wallet.py                       |       8 +++++++-
       
       1 file changed, 7 insertions(+), 1 deletion(-)
       ---
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -36,6 +36,8 @@ from account import *
        from transaction import Transaction
        from plugins import run_hook
        
       +COINBASE_MATURITY = 100
       +
        # AES encryption
        EncodeAES = lambda secret, s: base64.b64encode(aes.encryptData(secret,s))
        DecodeAES = lambda secret, e: aes.decryptData(secret, base64.b64decode(e))
       t@@ -979,12 +981,14 @@ class Wallet:
                    for tx_hash, tx_height in h:
                        tx = self.transactions.get(tx_hash)
                        if tx is None: raise BaseException("Wallet not synchronized")
       +                is_coinbase = tx.inputs[0].get('prevout_hash') == '0'*64
                        for output in tx.d.get('outputs'):
                            if output.get('address') != addr: continue
                            key = tx_hash + ":%d" % output.get('prevout_n')
                            if key in self.spent_outputs: continue
                            output['prevout_hash'] = tx_hash
                            output['height'] = tx_height
       +                    output['coinbase'] = is_coinbase
                            coins.append((tx_height, output))
        
                # sort by age
       t@@ -1024,7 +1028,9 @@ class Wallet:
                inputs = []
                coins = prioritized_coins + coins
        
       -        for item in coins: 
       +        for item in coins:
       +            if item.get('coinbase') and item.get('height') + COINBASE_MATURITY > self.network.blockchain.height:
       +                continue
                    addr = item.get('address')
                    v = item.get('value')
                    total += v