Browse Source

fix ledger sign_transaction, issue #1938

283
ThomasV 8 years ago
parent
commit
f26262da0f
  1. 21
      plugins/ledger/ledger.py

21
plugins/ledger/ledger.py

@ -257,28 +257,27 @@ class Ledger_KeyStore(Hardware_KeyStore):
p2shTransaction = False p2shTransaction = False
pin = "" pin = ""
self.get_client() # prompt for the PIN before displaying the dialog if necessary self.get_client() # prompt for the PIN before displaying the dialog if necessary
rawTx = tx.serialize()
# Fetch inputs of the transaction to sign # Fetch inputs of the transaction to sign
derivations = self.get_tx_derivations(tx)
for txin in tx.inputs(): for txin in tx.inputs():
if txin.get('is_coinbase'): if txin.get('is_coinbase'):
self.give_error("Coinbase not supported") # should never happen self.give_error("Coinbase not supported") # should never happen
redeemScript = None redeemScript = None
signingPos = -1
xpub, s = parse_xpubkey(txin['x_pubkeys'][0])
hwAddress = "%s/%d/%d" % (self.get_derivation()[2:], s[0], s[1])
if len(txin['pubkeys']) > 1: if len(txin['pubkeys']) > 1:
p2shTransaction = True p2shTransaction = True
if 'redeemScript' in txin: if 'redeemScript' in txin:
redeemScript = txin['redeemScript'] redeemScript = txin['redeemScript']
if p2shTransaction:
chipPublicKey = compress_public_key(self.get_client().getWalletPublicKey(hwAddress)['publicKey']) for i, x_pubkey in enumerate(txin['x_pubkeys']):
for currentIndex, key in enumerate(txin['pubkeys']): if x_pubkey in derivations:
if chipPublicKey == key.decode('hex'): signingPos = i
signingPos = currentIndex s = derivations.get(x_pubkey)
hwAddress = "%s/%d/%d" % (self.get_derivation()[2:], s[0], s[1])
break break
if signingPos == -1: else:
self.give_error("No matching key for multisignature input") # should never happen self.give_error("No matching x_key for sign_transaction") # should never happen
inputs.append([txin['prev_tx'].raw, txin['prevout_n'], redeemScript, txin['prevout_hash'], signingPos ]) inputs.append([txin['prev_tx'].raw, txin['prevout_n'], redeemScript, txin['prevout_hash'], signingPos ])
inputsPaths.append(hwAddress) inputsPaths.append(hwAddress)

Loading…
Cancel
Save