tmove estimate_fee back to wallet - electrum - Electrum Bitcoin wallet
 (HTM) git clone https://git.parazyd.org/electrum
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
       ---
 (DIR) commit eb36884c6685ef87a262d10524771692ba93faf6
 (DIR) parent 0b54ed02430533ab4c054feeac60988d53674f91
 (HTM) Author: ThomasV <thomasv@electrum.org>
       Date:   Tue,  2 Feb 2016 12:26:28 +0100
       
       move estimate_fee back to wallet
       
       Diffstat:
         M lib/commands.py                     |       3 +--
         M lib/transaction.py                  |      13 -------------
         M lib/wallet.py                       |      12 +++++++-----
         M plugins/trustedcoin/trustedcoin.py  |       5 -----
       
       4 files changed, 8 insertions(+), 25 deletions(-)
       ---
 (DIR) diff --git a/lib/commands.py b/lib/commands.py
       t@@ -404,8 +404,7 @@ class Commands:
                                self.wallet.add_input_info(i)
                            output = (TYPE_ADDRESS, address, amount)
                            dummy_tx = Transaction.from_io(inputs, [output])
       -                    fee_per_kb = self.wallet.fee_per_kb(self.config)
       -                    fee = dummy_tx.estimated_fee(fee_per_kb)
       +                    fee = self.wallet.estimate_fee(self.config, dummy_tx.estimated_size())
                        amount -= fee
                    else:
                        amount = int(COIN*Decimal(amount))
 (DIR) diff --git a/lib/transaction.py b/lib/transaction.py
       t@@ -715,15 +715,6 @@ class Transaction:
            def is_final(self):
                return not any([x.get('sequence') < 0xffffffff - 1 for x in self.inputs()])
        
       -    @classmethod
       -    def fee_for_size(self, relay_fee, fee_per_kb, size):
       -        '''Given a fee per kB in satoshis, and a tx size in bytes,
       -        returns the transaction fee.'''
       -        fee = int(fee_per_kb * size / 1000.)
       -        if fee < relay_fee:
       -            fee = relay_fee
       -        return fee
       -
            @profiler
            def estimated_size(self):
                '''Return an estimated tx size in bytes.'''
       t@@ -734,10 +725,6 @@ class Transaction:
                '''Return an estimated of serialized input size in bytes.'''
                return len(self.serialize_input(txin, -1, -1)) / 2
        
       -    def estimated_fee(self, relay_fee, fee_per_kb):
       -        '''Return an estimated fee given a fee per kB in satoshis.'''
       -        return self.fee_for_size(relay_fee, fee_per_kb, self.estimated_size())
       -
            def signature_count(self):
                r = 0
                s = 0
 (DIR) diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -662,8 +662,7 @@ class Abstract_Wallet(PrintError):
                output = (TYPE_ADDRESS, addr, sendable)
                dummy_tx = Transaction.from_io(inputs, [output])
                if fee is None:
       -            fee_per_kb = self.fee_per_kb(config)
       -            fee = dummy_tx.estimated_fee(self.relayfee(), fee_per_kb)
       +            fee = self.estimate_fee(config, dummy_tx.estimated_size())
                amount = max(0, sendable - fee)
                return amount, fee
        
       t@@ -957,9 +956,7 @@ class Abstract_Wallet(PrintError):
        
                # Fee estimator
                if fixed_fee is None:
       -            fee_estimator = partial(Transaction.fee_for_size,
       -                                    self.relayfee(),
       -                                    self.fee_per_kb(config))
       +            fee_estimator = partial(self.estimate_fee, config)
                else:
                    fee_estimator = lambda size: fixed_fee
        
       t@@ -978,6 +975,11 @@ class Abstract_Wallet(PrintError):
                run_hook('make_unsigned_transaction', self, tx)
                return tx
        
       +    def estimate_fee(self, config, size):
       +        fee = int(self.fee_per_kb(config) * size / 1000.)
       +        fee = max(fee, self.relayfee())
       +        return fee
       +
            def mktx(self, outputs, password, config, fee=None, change_addr=None, domain=None):
                coins = self.get_spendable_coins(domain)
                tx = self.make_unsigned_transaction(coins, outputs, config, fee, change_addr)
 (DIR) diff --git a/plugins/trustedcoin/trustedcoin.py b/plugins/trustedcoin/trustedcoin.py
       t@@ -221,11 +221,6 @@ class Wallet_2fa(Multisig_Wallet):
                    return 0
                return price
        
       -    def estimated_fee(self, tx, fee_per_kb):
       -        fee = tx.estimated_fee(fee_per_kb)
       -        fee += self.extra_fee(tx)
       -        return fee
       -
            def make_unsigned_transaction(self, coins, outputs, config,
                                          fixed_fee=None, change_addr=None):
                tx = BIP32_Wallet.make_unsigned_transaction(