Browse Source

trezor updates for python3

seed_v14
ThomasV 7 years ago
parent
commit
bb0174a8de
  1. 11
      plugins/trezor/plugin.py

11
plugins/trezor/plugin.py

@ -5,6 +5,7 @@ import threading
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from functools import partial from functools import partial
from electrum.util import bfh, bh2u
from electrum.bitcoin import (bc_address_to_hash_160, xpub_from_pubkey, from electrum.bitcoin import (bc_address_to_hash_160, xpub_from_pubkey,
public_key_to_p2pkh, EncodeBase58Check, public_key_to_p2pkh, EncodeBase58Check,
TYPE_ADDRESS, TYPE_SCRIPT, TYPE_ADDRESS, TYPE_SCRIPT,
@ -243,7 +244,7 @@ class TrezorCompatiblePlugin(HW_PluginBase):
inputs = self.tx_inputs(tx, True) inputs = self.tx_inputs(tx, True)
outputs = self.tx_outputs(keystore.get_derivation(), tx) outputs = self.tx_outputs(keystore.get_derivation(), tx)
signed_tx = client.sign_tx(self.get_coin_name(), inputs, outputs, lock_time=tx.locktime)[1] signed_tx = client.sign_tx(self.get_coin_name(), inputs, outputs, lock_time=tx.locktime)[1]
raw = signed_tx.encode('hex') raw = bh2u(signed_tx)
tx.update_signatures(raw) tx.update_signatures(raw)
def show_address(self, wallet, address): def show_address(self, wallet, address):
@ -277,14 +278,14 @@ class TrezorCompatiblePlugin(HW_PluginBase):
if is_xpubkey(x_pubkey): if is_xpubkey(x_pubkey):
xpub, s = parse_xpubkey(x_pubkey) xpub, s = parse_xpubkey(x_pubkey)
else: else:
xpub = xpub_from_pubkey(0, x_pubkey.decode('hex')) xpub = xpub_from_pubkey(0, bfh(x_pubkey))
s = [] s = []
node = self.ckd_public.deserialize(xpub) node = self.ckd_public.deserialize(xpub)
return self.types.HDNodePathType(node=node, address_n=s) return self.types.HDNodePathType(node=node, address_n=s)
pubkeys = map(f, x_pubkeys) pubkeys = map(f, x_pubkeys)
multisig = self.types.MultisigRedeemScriptType( multisig = self.types.MultisigRedeemScriptType(
pubkeys=pubkeys, pubkeys=pubkeys,
signatures=map(lambda x: x.decode('hex')[:-1] if x else '', txin.get('signatures')), signatures=map(lambda x: bfh(x)[:-1] if x else '', txin.get('signatures')),
m=txin.get('num_sig'), m=txin.get('num_sig'),
) )
txinputtype = self.types.TxInputType( txinputtype = self.types.TxInputType(
@ -307,7 +308,7 @@ class TrezorCompatiblePlugin(HW_PluginBase):
txinputtype.prev_index = prev_index txinputtype.prev_index = prev_index
if 'scriptSig' in txin: if 'scriptSig' in txin:
script_sig = txin['scriptSig'].decode('hex') script_sig = bfh(txin['scriptSig'])
txinputtype.script_sig = script_sig txinputtype.script_sig = script_sig
txinputtype.sequence = txin.get('sequence', 0xffffffff - 1) txinputtype.sequence = txin.get('sequence', 0xffffffff - 1)
@ -376,7 +377,7 @@ class TrezorCompatiblePlugin(HW_PluginBase):
for vout in d['outputs']: for vout in d['outputs']:
o = t.bin_outputs.add() o = t.bin_outputs.add()
o.amount = vout['value'] o.amount = vout['value']
o.script_pubkey = vout['scriptPubKey'].decode('hex') o.script_pubkey = bfh(vout['scriptPubKey'])
return t return t
# This function is called from the trezor libraries (via tx_api) # This function is called from the trezor libraries (via tx_api)

Loading…
Cancel
Save