FIX: disallow importing non-multisignature xpubs into multisig setup (closes #2437)

This commit is contained in:
Overtorment 2021-01-04 15:52:52 +00:00
parent cec73312da
commit 15a7b21c6a
3 changed files with 23 additions and 0 deletions

View File

@ -1082,4 +1082,16 @@ export class MultisigHDWallet extends AbstractHDElectrumWallet {
allowBatchSend() {
return true;
}
/**
* Returns TRUE only for _multisignature_ xpubs as per SLIP-0132
* (capital Z, capital Y, or just xpub)
* @see https://github.com/satoshilabs/slips/blob/master/slip-0132.md
*
* @param xpub
* @return {boolean}
*/
static isXpubForMultisig(xpub) {
return ['xpub', 'Ypub', 'Zpub'].includes(xpub.substring(0, 4));
}
}

View File

@ -486,6 +486,7 @@
"view_key": "View",
"invalid_mnemonics": "This mnemonic phrase doesnt seem to be valid",
"invalid_cosigner": "Not a valid cosigner data",
"not_a_multisignature_xpub": "This is not an xpub from multisignature wallet!",
"invalid_cosigner_format": "Incorrect cosigner: this is not a cosigner for {format} format",
"create_new_key": "Create New",
"scan_or_open_file": "Scan or open file",

View File

@ -259,6 +259,13 @@ const WalletsAddMultisigStep2 = () => {
};
const tryUsingXpub = async xpub => {
if (!MultisigHDWallet.isXpubForMultisig(xpub)) {
setIsProvideMnemonicsModalVisible(false);
setIsLoading(false);
setImportText('');
alert(loc.multisig.not_a_multisignature_xpub);
return;
}
let fp = await prompt(loc.multisig.input_fp, loc.multisig.input_fp_explain, false, 'plain-text');
fp = (fp + '').toUpperCase();
if (!MultisigHDWallet.isFpValid(fp)) fp = '00000000';
@ -319,6 +326,9 @@ const WalletsAddMultisigStep2 = () => {
setIsProvideMnemonicsModalVisible(true);
setImportText(ret.data);
} else {
if (MultisigHDWallet.isXpubValid(ret.data) && !MultisigHDWallet.isXpubForMultisig(ret.data)) {
return alert(loc.multisig.not_a_multisignature_xpub);
}
let cosigner = new MultisigCosigner(ret.data);
if (!cosigner.isValid()) return alert(loc.multisig.invalid_cosigner);
setIsProvideMnemonicsModalVisible(false);