FIX: import ms from Nunchuck (closes #5228)

This commit is contained in:
overtorment 2023-01-26 13:59:20 +00:00
parent 877982c38c
commit 9b537aa802
3 changed files with 26 additions and 4 deletions

View file

@ -567,11 +567,11 @@ export class MultisigHDWallet extends AbstractHDElectrumWallet {
}
if (secret.indexOf('sortedmulti(') !== -1 && json.descriptor) {
if (json.label) this.setLabel(json.label);
if (json.descriptor.startsWith('wsh(')) {
this.setNativeSegwit();
} else if (json.descriptor.startsWith('sh(wsh(')) {
if (json.descriptor.includes('sh(wsh(')) {
this.setWrappedSegwit();
} else if (json.descriptor.startsWith('sh(')) {
} else if (json.descriptor.includes('wsh(')) {
this.setNativeSegwit();
} else if (json.descriptor.includes('sh(')) {
this.setLegacy();
}

View file

@ -0,0 +1,4 @@
BSMS 1.0
wsh(sortedmulti(2,[3f5e4e09/48'/0'/0']xpub6BtEVX9WezWA2EYa8Wf1rJTokXpF96Rmqr4JKoR3SbjGw1vCa3Qb91mKN1AqJnBzSpqy44tEMB27Khne6KBmNzurXigfis7F28X5dRLWGoY/**,[b96bc7c7/48'/0'/0']xpub6CzCTuwFmAcBoxsfPLgiKfkJ2W3GbW1zxFKvCamZQ1J2XMobJR1gMNqP64pcFsy65ST4WcZtrCn99WXgLcWM6bqw6iFneAPTgJuLHggHD5S/**,[44437f41/48'/0'/0']xpub6Cn4cYgRhXKnvNjE4ULP2mzWHFw4WtCyp1nBuE97SyZVTPwq5xWkKsTVe9c16XSTr6V9AKMDgizav7z69j4AREaMKoFzUDbdcZhVq5xaKMU/**))
/0/*,/1/*
bc1qjppd555998lvpgdew30kdrvu2qg90n5gg684khrc2u5g7kj8cnuqujvz3p

View file

@ -2146,6 +2146,24 @@ describe('multisig-cosigner', () => {
}
});
it('can parse files from Nunchuck', () => {
const secrets = [[require('fs').readFileSync('./tests/unit/fixtures/nunchuck-bsms.txt', 'ascii'), true]];
for (const [s, verifyFingerprints] of secrets) {
const w = new MultisigHDWallet();
w.setSecret(s);
if (verifyFingerprints) {
assert.strictEqual(w.getFingerprint(1), '3F5E4E09');
assert.strictEqual(w.getFingerprint(2), 'B96BC7C7');
assert.strictEqual(w.getFingerprint(3), '44437F41');
}
assert.ok(w.isNativeSegwit());
assert.strictEqual(w._getExternalAddressByIndex(0), 'bc1qjppd555998lvpgdew30kdrvu2qg90n5gg684khrc2u5g7kj8cnuqujvz3p');
}
});
it('can export to json', () => {
const result = MultisigCosigner.exportToJson(fp1cobo, Zpub1, "m/48'/0'/0'/2'");
assert.strictEqual(