REF: easier pairing with HW wallets

This commit is contained in:
Overtorment 2021-04-19 12:09:35 +01:00
parent fb014c3eee
commit d428834f16
2 changed files with 9 additions and 0 deletions

View file

@ -194,6 +194,8 @@ export class AbstractWallet {
}
this.secret = parsedSecret.keystore.xpub;
this.masterFingerprint = masterFingerprint;
if (parsedSecret.keystore.type === 'hardware') this.use_with_hardware_wallet = true;
}
// It is a Cobo Vault Hardware Wallet
if (parsedSecret && parsedSecret.ExtPubKey && parsedSecret.MasterFingerprint) {
@ -201,6 +203,7 @@ export class AbstractWallet {
const mfp = Buffer.from(parsedSecret.MasterFingerprint, 'hex').reverse().toString('hex');
this.masterFingerprint = parseInt(mfp, 16);
this.setLabel('Cobo Vault ' + parsedSecret.MasterFingerprint);
if (parsedSecret.CoboVaultFirmwareVersion) this.use_with_hardware_wallet = true;
}
} catch (_) {}
return this;

View file

@ -19,6 +19,7 @@ describe('Watch only wallet', () => {
[secret.toUpperCase()],
);
assert.strictEqual(w.isHd(), false);
assert.ok(!w.useWithHardwareWalletEnabled());
}
w.setSecret('not valid');
@ -35,6 +36,7 @@ describe('Watch only wallet', () => {
assert.strictEqual(w.getMasterFingerprint(), false);
assert.strictEqual(w.getMasterFingerprintHex(), '00000000');
assert.ok(w.isXpubValid(), w.secret);
assert.ok(!w.useWithHardwareWalletEnabled());
}
});
@ -102,6 +104,7 @@ describe('Watch only wallet', () => {
);
assert.strictEqual(w.getMasterFingerprint(), 64392470);
assert.strictEqual(w.getMasterFingerprintHex(), '168dd603');
assert.ok(w.useWithHardwareWalletEnabled());
const utxos = [
{
@ -140,6 +143,7 @@ describe('Watch only wallet', () => {
);
assert.strictEqual(w.getMasterFingerprint(), 64392470);
assert.strictEqual(w.getMasterFingerprintHex(), '168dd603');
assert.ok(w.useWithHardwareWalletEnabled());
const utxos = [
{
@ -179,6 +183,7 @@ describe('Watch only wallet', () => {
assert.strictEqual(w.getMasterFingerprint(), 1908437330);
assert.strictEqual(w.getMasterFingerprintHex(), '5271c071');
assert.strictEqual(w.getLabel(), 'Cobo Vault 5271c071');
assert.ok(w.useWithHardwareWalletEnabled());
});
it('can import zpub with master fingerprint', async () => {
@ -192,6 +197,7 @@ describe('Watch only wallet', () => {
);
assert.strictEqual(w.getMasterFingerprint(), 4167290508);
assert.strictEqual(w.getMasterFingerprintHex(), '8cce63f8');
assert.ok(!w.useWithHardwareWalletEnabled());
});
it('can combine signed PSBT and prepare it for broadcast', async () => {