show address on trezor for multisig (#3823)
* show address on trezor for multisig * Show menu option properly. * remove useless line
This commit is contained in:
@@ -243,23 +243,39 @@ class TrezorCompatiblePlugin(HW_PluginBase):
|
|||||||
raw = bh2u(signed_tx)
|
raw = bh2u(signed_tx)
|
||||||
tx.update_signatures(raw)
|
tx.update_signatures(raw)
|
||||||
|
|
||||||
def show_address(self, wallet, address):
|
def show_address(self, wallet, keystore, address):
|
||||||
client = self.get_client(wallet.keystore)
|
client = self.get_client(keystore)
|
||||||
if not client.atleast_version(1, 3):
|
if not client.atleast_version(1, 3):
|
||||||
wallet.keystore.handler.show_error(_("Your device firmware is too old"))
|
keystore.handler.show_error(_("Your device firmware is too old"))
|
||||||
return
|
return
|
||||||
change, index = wallet.get_address_index(address)
|
change, index = wallet.get_address_index(address)
|
||||||
derivation = wallet.keystore.derivation
|
derivation = keystore.derivation
|
||||||
address_path = "%s/%d/%d"%(derivation, change, index)
|
address_path = "%s/%d/%d"%(derivation, change, index)
|
||||||
address_n = client.expand_path(address_path)
|
address_n = client.expand_path(address_path)
|
||||||
script_gen = wallet.keystore.get_script_gen()
|
xpubs = wallet.get_master_public_keys()
|
||||||
if script_gen == SCRIPT_GEN_NATIVE_SEGWIT:
|
if len(xpubs) == 1:
|
||||||
script_type = self.types.InputScriptType.SPENDWITNESS
|
script_gen = keystore.get_script_gen()
|
||||||
elif script_gen == SCRIPT_GEN_P2SH_SEGWIT:
|
if script_gen == SCRIPT_GEN_NATIVE_SEGWIT:
|
||||||
script_type = self.types.InputScriptType.SPENDP2SHWITNESS
|
script_type = self.types.InputScriptType.SPENDWITNESS
|
||||||
|
elif script_gen == SCRIPT_GEN_P2SH_SEGWIT:
|
||||||
|
script_type = self.types.InputScriptType.SPENDP2SHWITNESS
|
||||||
|
else:
|
||||||
|
script_type = self.types.InputScriptType.SPENDADDRESS
|
||||||
|
client.get_address(self.get_coin_name(), address_n, True, script_type=script_type)
|
||||||
else:
|
else:
|
||||||
script_type = self.types.InputScriptType.SPENDADDRESS
|
def f(xpub):
|
||||||
client.get_address(self.get_coin_name(), address_n, True, script_type=script_type)
|
node = self.ckd_public.deserialize(xpub)
|
||||||
|
return self.types.HDNodePathType(node=node, address_n=[change, index])
|
||||||
|
pubkeys = wallet.get_public_keys(address)
|
||||||
|
# sort xpubs using the order of pubkeys
|
||||||
|
sorted_pubkeys, sorted_xpubs = zip(*sorted(zip(pubkeys, xpubs)))
|
||||||
|
pubkeys = list(map(f, sorted_xpubs))
|
||||||
|
multisig = self.types.MultisigRedeemScriptType(
|
||||||
|
pubkeys=pubkeys,
|
||||||
|
signatures=[b''] * wallet.n,
|
||||||
|
m=wallet.m,
|
||||||
|
)
|
||||||
|
client.get_address(self.get_coin_name(), address_n, True, multisig=multisig)
|
||||||
|
|
||||||
def tx_inputs(self, tx, for_sig=False, script_gen=SCRIPT_GEN_LEGACY):
|
def tx_inputs(self, tx, for_sig=False, script_gen=SCRIPT_GEN_LEGACY):
|
||||||
inputs = []
|
inputs = []
|
||||||
|
|||||||
@@ -188,13 +188,14 @@ class QtPlugin(QtPluginBase):
|
|||||||
|
|
||||||
@hook
|
@hook
|
||||||
def receive_menu(self, menu, addrs, wallet):
|
def receive_menu(self, menu, addrs, wallet):
|
||||||
if type(wallet) is not Standard_Wallet:
|
if len(addrs) != 1:
|
||||||
return
|
return
|
||||||
keystore = wallet.get_keystore()
|
for keystore in wallet.get_keystores():
|
||||||
if type(keystore) == self.keystore_class and len(addrs) == 1:
|
if type(keystore) == self.keystore_class:
|
||||||
def show_address():
|
def show_address():
|
||||||
keystore.thread.add(partial(self.show_address, wallet, addrs[0]))
|
keystore.thread.add(partial(self.show_address, wallet, keystore, addrs[0]))
|
||||||
menu.addAction(_("Show on %s") % self.device, show_address)
|
menu.addAction(_("Show on %s") % self.device, show_address)
|
||||||
|
break
|
||||||
|
|
||||||
def show_settings_dialog(self, window, keystore):
|
def show_settings_dialog(self, window, keystore):
|
||||||
device_id = self.choose_device(window, keystore)
|
device_id = self.choose_device(window, keystore)
|
||||||
|
|||||||
Reference in New Issue
Block a user