mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-20 18:21:57 +01:00
Merge branch 'master' into safearea
This commit is contained in:
commit
aa0246ab3d
@ -7,17 +7,22 @@ import { BlueStorageContext } from '../blue_modules/storage-context';
|
||||
|
||||
function DeviceQuickActions() {
|
||||
DeviceQuickActions.STORAGE_KEY = 'DeviceQuickActionsEnabled';
|
||||
const { wallets, walletsInitialized, isStorageEncryted } = useContext(BlueStorageContext);
|
||||
const { wallets, walletsInitialized, isStorageEncrypted } = useContext(BlueStorageContext);
|
||||
|
||||
useEffect(() => {
|
||||
if (walletsInitialized) {
|
||||
if (isStorageEncryted) {
|
||||
QuickActions.clearShortcutItems();
|
||||
} else {
|
||||
setQuickActions();
|
||||
}
|
||||
isStorageEncrypted()
|
||||
.then(value => {
|
||||
if (value) {
|
||||
QuickActions.clearShortcutItems();
|
||||
} else {
|
||||
setQuickActions();
|
||||
}
|
||||
})
|
||||
.catch(() => QuickActions.clearShortcutItems());
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wallets, walletsInitialized, isStorageEncryted]);
|
||||
}, [wallets, walletsInitialized]);
|
||||
|
||||
DeviceQuickActions.setEnabled = (enabled = true) => {
|
||||
return AsyncStorage.setItem(DeviceQuickActions.STORAGE_KEY, JSON.stringify(enabled)).then(() => {
|
||||
|
@ -554,15 +554,17 @@ export class MultisigHDWallet extends AbstractHDElectrumWallet {
|
||||
// is it wallet descriptor?
|
||||
// @see https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md
|
||||
// @see https://github.com/Fonta1n3/FullyNoded/blob/master/Docs/Wallets/Wallet-Export-Spec.md
|
||||
if (!json && secret.indexOf('sortedmulti(')) {
|
||||
// provided secret was NOT json but plain wallet descriptor text. lets mock json
|
||||
json = { descriptor: secret, label: 'Multisig vault' };
|
||||
}
|
||||
if (secret.indexOf('sortedmulti(') !== -1 && json.descriptor) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import { AvailableLanguages } from './languages';
|
||||
const currency = require('../blue_modules/currency');
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
dayjs.extend(localizedFormat)
|
||||
dayjs.extend(localizedFormat);
|
||||
|
||||
// first-time loading sequence
|
||||
|
||||
|
@ -1510,6 +1510,65 @@ 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 secrets = [
|
||||
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',
|
||||
}),
|
||||
'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',
|
||||
];
|
||||
|
||||
for (const secret of secrets) {
|
||||
const w = new MultisigHDWallet();
|
||||
w.setSecret(secret);
|
||||
assert.strictEqual(w.getM(), 2);
|
||||
assert.strictEqual(w.getN(), 3);
|
||||
assert.strictEqual(w._getExternalAddressByIndex(0), '3GSZaKT3LujScx6JeWejc6xjZsCDRzptsA');
|
||||
assert.strictEqual(w._getExternalAddressByIndex(1), '3GT11kStn8W6q2kj257uZqW9xEKJwPMDkw');
|
||||
assert.ok(w.getLabel() === 'nested2of3' || w.getLabel() === 'Multisig vault');
|
||||
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(ww.getFingerprint(1), '99FE7770');
|
||||
});
|
||||
|
||||
it('can edit cosigners', () => {
|
||||
const path = "m/48'/0'/0'/2'";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user