mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-01-19 05:45:15 +01:00
FIX: disallow importing non-multisignature xpubs into multisig setup (closes #2437)
This commit is contained in:
parent
cec73312da
commit
15a7b21c6a
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -486,6 +486,7 @@
|
||||
"view_key": "View",
|
||||
"invalid_mnemonics": "This mnemonic phrase doesn’t 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",
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user