mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
Merge pull request #3921 from BlueWallet/fix-path-from-hw-watchonly-wallets
FIX: correct path when importing watch-only from hardware wallet
This commit is contained in:
commit
3c13e659ae
@ -261,7 +261,7 @@ export class AbstractWallet {
|
||||
this.secret = parsedSecret.ExtPubKey;
|
||||
const mfp = Buffer.from(parsedSecret.MasterFingerprint, 'hex').reverse().toString('hex');
|
||||
this.masterFingerprint = parseInt(mfp, 16);
|
||||
this._derivationPath = `m/${parsedSecret.AccountKeyPath}`;
|
||||
this._derivationPath = parsedSecret.AccountKeyPath.startsWith('m/') ? parsedSecret.AccountKeyPath : `m/${parsedSecret.AccountKeyPath}`;
|
||||
if (parsedSecret.CoboVaultFirmwareVersion) this.use_with_hardware_wallet = true;
|
||||
}
|
||||
} catch (_) {}
|
||||
|
@ -362,6 +362,20 @@ describe('import procedure', () => {
|
||||
);
|
||||
await promise;
|
||||
assert.strictEqual(store.state.wallets[0].type, WatchOnlyWallet.type);
|
||||
assert.strictEqual(store.state.wallets[0].getDerivationPath(), "m/84'/0'/0'");
|
||||
});
|
||||
|
||||
it('can import watch-only Keystone vault export', async () => {
|
||||
const store = createStore();
|
||||
const { promise } = startImport(
|
||||
'{"ExtPubKey":"zpub6qT7amLcp2exr4mU4AhXZMjD9CFkopECVhUxc9LHW8pNsJG2B9ogs5sFbGZpxEeT5TBjLmc7EFYgZA9EeWEM1xkJMFLefzZc8eigRFhKB8Q","MasterFingerprint":"01EBDA7D","AccountKeyPath":"m/84\'/0\'/0\'"}',
|
||||
false,
|
||||
false,
|
||||
...store.callbacks,
|
||||
);
|
||||
await promise;
|
||||
assert.strictEqual(store.state.wallets[0].type, WatchOnlyWallet.type);
|
||||
assert.strictEqual(store.state.wallets[0].getDerivationPath(), "m/84'/0'/0'");
|
||||
});
|
||||
|
||||
it('can import BIP39 wallets with truncated words', async () => {
|
||||
|
@ -438,6 +438,11 @@ describe('BC-UR', () => {
|
||||
Buffer.from(decoded, 'hex').toString('ascii'),
|
||||
'{"ExtPubKey":"zpub6qT7amLcp2exr4mU4AhXZMjD9CFkopECVhUxc9LHW8pNsJG2B9ogs5sFbGZpxEeT5TBjLmc7EFYgZA9EeWEM1xkJMFLefzZc8eigRFhKB8Q","MasterFingerprint":"01EBDA7D","AccountKeyPath":"m/84\'/0\'/0\'"}',
|
||||
);
|
||||
|
||||
const w = new WatchOnlyWallet();
|
||||
w.setSecret(Buffer.from(decoded, 'hex').toString('ascii'));
|
||||
w.init();
|
||||
assert.strictEqual(w.getDerivationPath(), "m/84'/0'/0'");
|
||||
});
|
||||
|
||||
it('v2: can decodeUR() PSBT', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user