mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
ADD: default derivation path for watch only wallets
This commit is contained in:
parent
30062e9795
commit
4ac9b6016b
2 changed files with 32 additions and 0 deletions
|
@ -224,6 +224,17 @@ export class AbstractWallet {
|
|||
if (parsedSecret.CoboVaultFirmwareVersion) this.use_with_hardware_wallet = true;
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
if (!this._derivationPath) {
|
||||
if (this.secret.startsWith('xpub')) {
|
||||
this._derivationPath = "m/44'/0'/0'"; // Assume default BIP44 path for legacy wallets
|
||||
} else if (this.secret.startsWith('ypub')) {
|
||||
this._derivationPath = "m/49'/0'/0'"; // Assume default BIP49 path for segwit wrapped wallets
|
||||
} else if (this.secret.startsWith('zpub')) {
|
||||
this._derivationPath = "m/84'/0'/0'"; // Assume default BIP84 for native segwit wallets
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -340,6 +340,27 @@ describe('Watch only wallet', () => {
|
|||
);
|
||||
assert.strictEqual(psbt.data.outputs[1].bip32Derivation[0].path, "m/49'/0'/0'/1/46");
|
||||
});
|
||||
|
||||
it('xpub watch only has derivation path set to BIP44 default', () => {
|
||||
const w = new WatchOnlyWallet();
|
||||
w.setSecret('xpub6CQdfC3v9gU86eaSn7AhUFcBVxiGhdtYxdC5Cw2vLmFkfth2KXCMmYcPpvZviA89X6DXDs4PJDk5QVL2G2xaVjv7SM4roWHr1gR4xB3Z7Ps');
|
||||
|
||||
assert.strictEqual(w.getDerivationPath(), "m/44'/0'/0'");
|
||||
});
|
||||
|
||||
it('ypub watch only has derivation path set to BIP49 default', () => {
|
||||
const w = new WatchOnlyWallet();
|
||||
w.setSecret('ypub6Y9u3QCRC1HkZv3stNxcQVwmw7vC7KX5Ldz38En5P88RQbesP2oy16hNyQocVCfYRQPxdHcd3pmu9AFhLv7NdChWmw5iNLryZ2U6EEHdnfo');
|
||||
|
||||
assert.strictEqual(w.getDerivationPath(), "m/49'/0'/0'");
|
||||
});
|
||||
|
||||
it('zpub watch only has derivation path set to BIP84 default', () => {
|
||||
const w = new WatchOnlyWallet();
|
||||
w.setSecret('zpub6rjLjQVqVnj7crz9E4QWj4WgczmEseJq22u2B6k2HZr6NE2PQx3ZYg8BnbjN9kCfHymSeMd2EpwpM5iiz5Nrb3TzvddxW2RMcE3VXdVaXHk');
|
||||
|
||||
assert.strictEqual(w.getDerivationPath(), "m/84'/0'/0'");
|
||||
});
|
||||
});
|
||||
|
||||
describe('BC-UR', () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue