Browse Source

wallet.add_hw_info: minor clean-up

master
SomberNight 6 years ago
parent
commit
ac329797e0
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 15
      electrum/wallet.py

15
electrum/wallet.py

@ -1147,7 +1147,7 @@ class Abstract_Wallet(AddressSynchronizer):
return True return True
return False return False
def get_input_tx(self, tx_hash, *, ignore_network_issues=False): def get_input_tx(self, tx_hash, *, ignore_network_issues=False) -> Optional[Transaction]:
# First look up an input transaction in the wallet where it # First look up an input transaction in the wallet where it
# will likely be. If co-signing a transaction it may not have # will likely be. If co-signing a transaction it may not have
# all the input txs, in which case we ask the network. # all the input txs, in which case we ask the network.
@ -1165,7 +1165,7 @@ class Abstract_Wallet(AddressSynchronizer):
tx = Transaction(raw_tx) tx = Transaction(raw_tx)
return tx return tx
def add_hw_info(self, tx): def add_hw_info(self, tx: Transaction) -> None:
# add previous tx for hw wallets # add previous tx for hw wallets
for txin in tx.inputs(): for txin in tx.inputs():
tx_hash = txin['prevout_hash'] tx_hash = txin['prevout_hash']
@ -1175,15 +1175,14 @@ class Abstract_Wallet(AddressSynchronizer):
# add output info for hw wallets # add output info for hw wallets
info = {} info = {}
xpubs = self.get_master_public_keys() xpubs = self.get_master_public_keys()
for txout in tx.outputs(): for o in tx.outputs():
_type, addr, amount = txout if self.is_mine(o.address):
if self.is_mine(addr): index = self.get_address_index(o.address)
index = self.get_address_index(addr) pubkeys = self.get_public_keys(o.address)
pubkeys = self.get_public_keys(addr)
# sort xpubs using the order of pubkeys # sort xpubs using the order of pubkeys
sorted_pubkeys, sorted_xpubs = zip(*sorted(zip(pubkeys, xpubs))) sorted_pubkeys, sorted_xpubs = zip(*sorted(zip(pubkeys, xpubs)))
num_sig = self.m if isinstance(self, Multisig_Wallet) else None num_sig = self.m if isinstance(self, Multisig_Wallet) else None
info[addr] = TxOutputHwInfo(index, sorted_xpubs, num_sig, self.txin_type) info[o.address] = TxOutputHwInfo(index, sorted_xpubs, num_sig, self.txin_type)
tx.output_info = info tx.output_info = info
def sign_transaction(self, tx, password): def sign_transaction(self, tx, password):

Loading…
Cancel
Save