electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit a43b0395d451c6a52e116ac53106e91b05a3e596
parent 5aa0a87d7a796c78af180c46408f2f3a362a695f
Author: ThomasV <thomasv@electrum.org>
Date:   Tue,  2 Feb 2016 14:02:41 +0100

trustedcoin: do not call make_unsigned_transaction twice

Diffstat:
Mplugins/trustedcoin/trustedcoin.py | 20+++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/plugins/trustedcoin/trustedcoin.py b/plugins/trustedcoin/trustedcoin.py @@ -206,38 +206,36 @@ class Wallet_2fa(Multisig_Wallet): def can_sign_without_server(self): return self.master_private_keys.get('x2/') is not None - def extra_fee(self, tx=None): + def extra_fee(self): if self.can_sign_without_server(): return 0 if self.billing_info.get('tx_remaining'): return 0 if self.is_billing: return 0 - # trustedcoin won't charge if the total inputs is lower than their fee price = int(self.price_per_tx.get(1)) assert price <= 100000 - if tx and tx.input_value() < price: - self.print_error("not charging for this tx") - return 0 return price def make_unsigned_transaction(self, coins, outputs, config, fixed_fee=None, change_addr=None): - tx = BIP32_Wallet.make_unsigned_transaction( - self, coins, outputs, config, fixed_fee, change_addr) - # Plain TX was good. Now add trustedcoin fee. + mk_tx = lambda o: BIP32_Wallet.make_unsigned_transaction( + self, coins, o, config, fixed_fee, change_addr) fee = self.extra_fee() if fee: address = self.billing_info['billing_address'] - outputs = outputs + [(TYPE_ADDRESS, address, fee)] + fee_output = (TYPE_ADDRESS, address, fee) try: - return BIP32_Wallet.make_unsigned_transaction( - self, coins, outputs, config, fixed_fee, change_addr) + tx = mk_tx(outputs + [fee_output]) except NotEnoughFunds: # trustedcoin won't charge if the total inputs is # lower than their fee + tx = mk_tx(outputs) if tx.input_value() >= fee: raise + self.print_error("not charging for this tx") + else: + tx = mk_tx(outputs) return tx def sign_transaction(self, tx, password):