Skip to content

Commit

Permalink
Merge pull request #2983 from BlueWallet/add-easier-hw-pairing
Browse files Browse the repository at this point in the history
Add easier hw pairing
  • Loading branch information
GladosBlueWallet committed Apr 19, 2021
2 parents de8fd08 + b556996 commit 9b2fe7d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions class/wallets/abstract-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,16 @@ 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) {
this.secret = parsedSecret.ExtPubKey;
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;
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/lightning-custodian-wallet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('LightningCustodianWallet', () => {
},
body: '{"amount": "0.01", "currency": "USD"}',
});
if (!res.body.data || !res.body.data.lightning_invoice || !res.body.data.lightning_invoice.payreq) {
if (!res.body || !res.body.data || !res.body.data.lightning_invoice || !res.body.data.lightning_invoice.payreq) {
throw new Error('Opennode problem');
}

Expand Down
6 changes: 6 additions & 0 deletions tests/unit/watch-only-wallet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Watch only wallet', () => {
[secret.toUpperCase()],
);
assert.strictEqual(w.isHd(), false);
assert.ok(!w.useWithHardwareWalletEnabled());
}

w.setSecret('not valid');
Expand All @@ -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());
}
});

Expand Down Expand Up @@ -102,6 +104,7 @@ describe('Watch only wallet', () => {
);
assert.strictEqual(w.getMasterFingerprint(), 64392470);
assert.strictEqual(w.getMasterFingerprintHex(), '168dd603');
assert.ok(w.useWithHardwareWalletEnabled());

const utxos = [
{
Expand Down Expand Up @@ -140,6 +143,7 @@ describe('Watch only wallet', () => {
);
assert.strictEqual(w.getMasterFingerprint(), 64392470);
assert.strictEqual(w.getMasterFingerprintHex(), '168dd603');
assert.ok(w.useWithHardwareWalletEnabled());

const utxos = [
{
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down

0 comments on commit 9b2fe7d

Please sign in to comment.