mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-23 15:20:55 +01:00
FIX: Incorrect import from Specter - p2sh wrapped segwit multisig (closes #2451)
This commit is contained in:
parent
e26ca8372d
commit
b164d951cb
2 changed files with 55 additions and 5 deletions
|
@ -558,11 +558,9 @@ export class MultisigHDWallet extends AbstractHDElectrumWallet {
|
|||
if (json.label) this.setLabel(json.label);
|
||||
if (json.descriptor.startsWith('wsh(')) {
|
||||
this.setNativeSegwit();
|
||||
}
|
||||
if (json.descriptor.startsWith('sh(')) {
|
||||
this.setLegacy();
|
||||
}
|
||||
if (json.descriptor.startsWith('sh(wsh(')) {
|
||||
} else if (json.descriptor.startsWith('sh(wsh(')) {
|
||||
this.setWrappedSegwit();
|
||||
} else if (json.descriptor.startsWith('sh(')) {
|
||||
this.setLegacy();
|
||||
}
|
||||
|
||||
|
|
|
@ -1510,6 +1510,58 @@ describe('multisig-wallet (native segwit)', () => {
|
|||
assert.strictEqual(w.getDerivationPath(), '');
|
||||
});
|
||||
|
||||
it('can import from specter-desktop/fullynoded (p2sh-p2wsh)', () => {
|
||||
// @see https://github.com/Fonta1n3/FullyNoded/blob/master/Docs/Wallets/Wallet-Export-Spec.md
|
||||
const json = JSON.stringify({
|
||||
label: 'nested2of3',
|
||||
blockheight: 481824,
|
||||
descriptor:
|
||||
'sh(wsh(sortedmulti(2,[99fe7770/48h/0h/0h/1h]xpub6FEEbEaYM9pmY8rxz4g6AuaJVszwKt8g6cFg9nFWeE85EdBrGBcnhHqXAaPbQ4Hi3Xu9vijtYdYnNjERw9eSniF3235Vjde11GieeHjv7XT/0/*,[636bdad0/48h/0h/0h/1h]xpub6F67TyyWngU5rkVPxHTdmuYkaXHXeRwwVg5SsDeiPPjt6Mithh4Qzpu2yHjNa5W7nhcTbV6QaJMvppYMDSnB3SxArCkp9GvHQqpr5P17yFv/0/*,[99c90b2f/48h/0h/0h/1h]xpub6E6FyTrwmuUYeRMULXSAGvUKeP5ba6pQKVhWNuvVZFmGPnDYb9m5vP2XsSEQ4gKUGfXtLcKs4AV31vpfx2P5KuWm9co4HM3FtGov8enmJ6f/0/*)))#wy7xtlnw',
|
||||
});
|
||||
const w = new MultisigHDWallet();
|
||||
w.setSecret(json);
|
||||
assert.strictEqual(w.getM(), 2);
|
||||
assert.strictEqual(w.getN(), 3);
|
||||
assert.strictEqual(w._getExternalAddressByIndex(0), '3GSZaKT3LujScx6JeWejc6xjZsCDRzptsA');
|
||||
assert.strictEqual(w._getExternalAddressByIndex(1), '3GT11kStn8W6q2kj257uZqW9xEKJwPMDkw');
|
||||
assert.strictEqual(w.getLabel(), 'nested2of3');
|
||||
assert.ok(w.isWrappedSegwit());
|
||||
assert.ok(!w.isNativeSegwit());
|
||||
assert.ok(!w.isLegacy());
|
||||
|
||||
assert.strictEqual(w.getFingerprint(1), '99FE7770');
|
||||
assert.strictEqual(w.getFingerprint(2), '636BDAD0');
|
||||
assert.strictEqual(w.getFingerprint(3), '99C90B2F');
|
||||
|
||||
assert.strictEqual(
|
||||
w.getCosigner(1),
|
||||
'xpub6FEEbEaYM9pmY8rxz4g6AuaJVszwKt8g6cFg9nFWeE85EdBrGBcnhHqXAaPbQ4Hi3Xu9vijtYdYnNjERw9eSniF3235Vjde11GieeHjv7XT',
|
||||
);
|
||||
assert.strictEqual(
|
||||
w.getCosigner(2),
|
||||
'xpub6F67TyyWngU5rkVPxHTdmuYkaXHXeRwwVg5SsDeiPPjt6Mithh4Qzpu2yHjNa5W7nhcTbV6QaJMvppYMDSnB3SxArCkp9GvHQqpr5P17yFv',
|
||||
);
|
||||
assert.strictEqual(
|
||||
w.getCosigner(3),
|
||||
'xpub6E6FyTrwmuUYeRMULXSAGvUKeP5ba6pQKVhWNuvVZFmGPnDYb9m5vP2XsSEQ4gKUGfXtLcKs4AV31vpfx2P5KuWm9co4HM3FtGov8enmJ6f',
|
||||
);
|
||||
|
||||
assert.strictEqual(w.getCustomDerivationPathForCosigner(1), "m/48'/0'/0'/1'");
|
||||
assert.strictEqual(w.getCustomDerivationPathForCosigner(2), "m/48'/0'/0'/1'");
|
||||
assert.strictEqual(w.getCustomDerivationPathForCosigner(3), "m/48'/0'/0'/1'");
|
||||
assert.strictEqual(w.getDerivationPath(), '');
|
||||
|
||||
const ww = new MultisigHDWallet();
|
||||
ww.addCosigner('equal emotion skin exchange scale inflict half expose awkward deliver series broken');
|
||||
ww.addCosigner('spatial road snack luggage buddy media seek charge people pool neither family');
|
||||
ww.addCosigner('sing author lyrics expand ladder embody frost rapid survey similar flight unknown');
|
||||
ww.setM(2);
|
||||
ww.setDerivationPath("m/48'/0'/0'/1'");
|
||||
ww.setWrappedSegwit();
|
||||
assert.strictEqual(ww._getExternalAddressByIndex(0), '3GSZaKT3LujScx6JeWejc6xjZsCDRzptsA');
|
||||
assert.strictEqual(w.getFingerprint(1), '99FE7770');
|
||||
});
|
||||
|
||||
it('can edit cosigners', () => {
|
||||
const path = "m/48'/0'/0'/2'";
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue