URI: 
       tAvoid index-out-of-range - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 0a3d74de8f2fa8eece37f4b728fb62a5b0658418
   DIR parent 25a2ceda237768c692fe9220efd05398d62d6a57
  HTML Author: Neil Booth <kyuupichan@gmail.com>
       Date:   Sun, 20 Dec 2015 12:19:44 +0900
       
       Avoid index-out-of-range
       
       Also add sanity assertion
       
       Diffstat:
         M lib/coinchooser.py                  |       1 +
         M lib/wallet.py                       |       6 +++++-
       
       2 files changed, 6 insertions(+), 1 deletion(-)
       ---
   DIR diff --git a/lib/coinchooser.py b/lib/coinchooser.py
       t@@ -67,6 +67,7 @@ class CoinChooserBase(PrintError):
                amounts = self.change_amounts(tx, len(change_addrs), fee_estimator,
                                              dust_threshold)
                assert min(amounts) >= 0
       +        assert len(change_addrs) >= len(amounts)
                # If change is above dust threshold after accounting for the
                # size of the change output, add it to the transaction.
                dust = sum(amount for amount in amounts if amount < dust_threshold)
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -26,7 +26,7 @@ import json
        import copy
        from functools import partial
        
       -from util import PrintError, profiler
       +from util import NotEnoughFunds, PrintError, profiler
        
        from bitcoin import *
        from account import *
       t@@ -897,6 +897,10 @@ class Abstract_Wallet(PrintError):
                    if type == 'address':
                        assert is_address(data), "Address " + data + " is invalid!"
        
       +        # Avoid index-out-of-range with coins[0] below
       +        if not coins:
       +            raise NotEnoughFunds()
       +
                for item in coins:
                    self.add_input_info(item)