electrum

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

commit 9aa3f2d9e29d9c0d4cec7336c6a2140bad8b77c2
parent d28f6034835dfea922dc30ff4110be40651fb4c4
Author: ThomasV <thomasv@electrum.org>
Date:   Sat,  7 Oct 2017 12:15:18 +0200

add txin_type in add_input_info, remove inefficient search

Diffstat:
Mlib/transaction.py | 1+
Mlib/wallet.py | 12++----------
2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/lib/transaction.py b/lib/transaction.py @@ -474,6 +474,7 @@ def deserialize(raw): for i in range(n_vin): txin = d['inputs'][i] parse_witness(vds, txin) + # segwit-native script if not txin.get('scriptSig'): if txin['num_sig'] == 1: txin['type'] = 'p2wpkh' diff --git a/lib/wallet.py b/lib/wallet.py @@ -1072,15 +1072,9 @@ class Abstract_Wallet(PrintError): return Transaction.from_io(inputs, outputs) def add_input_info(self, txin): - txin['type'] = self.txin_type - # Add address for utxo that are in wallet - if txin.get('scriptSig') == '': - coins = self.get_utxos() - for item in coins: - if txin.get('prevout_hash') == item.get('prevout_hash') and txin.get('prevout_n') == item.get('prevout_n'): - txin['address'] = item.get('address') address = txin['address'] if self.is_mine(address): + txin['type'] = self.get_txin_type(address) self.add_input_sig_info(txin, address) def can_sign(self, tx): @@ -1464,15 +1458,13 @@ class Imported_Wallet(Abstract_Wallet): return self.addresses[address].get('type', 'address') def add_input_sig_info(self, txin, address): - txin['type'] = self.get_txin_type(address) if self.is_watching_only(): addrtype, hash160 = b58_address_to_hash160(address) x_pubkey = 'fd' + bh2u(bytes([addrtype]) + hash160) txin['x_pubkeys'] = [x_pubkey] txin['signatures'] = [None] return - - if txin_type in ['p2pkh', 'p2wkh', 'p2wkh-p2sh']: + if txin['type'] in ['p2pkh', 'p2wkh', 'p2wkh-p2sh']: pubkey = self.addresses[address]['pubkey'] txin['num_sig'] = 1 txin['x_pubkeys'] = [pubkey]