From b78b0776060ff69a9f2c6a1cd050b0dfc7efb0b2 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Mon, 23 Nov 2020 14:28:28 +0100 Subject: [PATCH] bitbox02: more robust account keypath In multisig, we plan to allow other kinds of keypaths that are not exactly 4 elements long. This change allows parsing the account keypath for any kind of keypath, assuming the last two element are /change/address. --- electrum/plugins/bitbox02/bitbox02.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/electrum/plugins/bitbox02/bitbox02.py b/electrum/plugins/bitbox02/bitbox02.py index 5432f66d9..ff09fef5e 100644 --- a/electrum/plugins/bitbox02/bitbox02.py +++ b/electrum/plugins/bitbox02/bitbox02.py @@ -293,8 +293,7 @@ class BitBox02Client(HardwareClientBase): raise Exception( "Need to setup communication first before attempting any BitBox02 calls" ) - - account_keypath = bip32_path[:4] + account_keypath = bip32_path[:-2] xpubs = wallet.get_master_public_keys() our_xpub = self.get_xpub( bip32.convert_bip32_intpath_to_strpath(account_keypath), xtype @@ -504,15 +503,7 @@ class BitBox02Client(HardwareClientBase): ) ) - if type(wallet) is Standard_Wallet: - keypath_account = full_path[:3] - elif type(wallet) is Multisig_Wallet: - keypath_account = full_path[:4] - else: - raise Exception( - "BitBox02 does not support this wallet type: {}".format(type(wallet)) - ) - + keypath_account = full_path[:-2] sigs = self.bitbox02_device.btc_sign( coin, [bitbox02.btc.BTCScriptConfigWithKeypath(