fix: enforce the base58 checksum and reject non-master extended keys (closes #210)
check / check (push) Has been cancelled

此提交已合并在合并请求 #232 中。
这个提交包含在:
2026-08-11 15:31:50 +02:00
父节点 fb9e8f5542
当前提交 b155c0fcd6
共修改 5 个文件,包含 238 行新增和 30 行删除
+14 -2
查看文件
@@ -6,6 +6,7 @@ const {
addressFromPrivateKey,
hdWalletFromXprv,
isValidXprv,
isMasterExtendedKey,
} = require("../../shared/wallet");
const { encryptWithPassword } = require("../../shared/vault");
const { state, saveState } = require("../../shared/state");
@@ -213,14 +214,25 @@ async function importXprvKey(ctx) {
return;
}
if (!isValidXprv(xprv)) {
showFlash("Invalid extended private key.");
showFlash(
"That extended private key is not valid. Please check it and try again.",
);
return;
}
if (!isMasterExtendedKey(xprv)) {
showFlash(
"That is an account-level or child key, which cannot be imported. " +
"Please paste the master extended private key for the wallet.",
);
return;
}
let result;
try {
result = hdWalletFromXprv(xprv);
} catch (e) {
showFlash("Invalid extended private key.");
showFlash(
"That extended private key is not valid. Please check it and try again.",
);
return;
}
const { xpub, firstAddress } = result;