mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
initpegoutwallet: check for hardened derivation steps early
This commit is contained in:
parent
c0e0e0a9d5
commit
a7b41e1f7e
1 changed files with 13 additions and 10 deletions
|
|
@ -5136,6 +5136,19 @@ UniValue initpegoutwallet(const JSONRPCRequest& request)
|
|||
throw JSONRPCError(RPC_INVALID_PARAMETER, "bitcoin_descriptor must be a ranged descriptor.");
|
||||
}
|
||||
|
||||
// Check if we can actually generate addresses(catches hardened derivation steps etc) before
|
||||
// writing to cache
|
||||
UniValue address_list(UniValue::VARR);
|
||||
for (int i = counter; i < counter+3; i++) {
|
||||
std::vector<CScript> scripts;
|
||||
if (!desc->Expand(i, provider, scripts, provider)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Could not generate lookahead addresses with descriptor. Are there hardened derivations after the xpub?");
|
||||
}
|
||||
CTxDestination destination;
|
||||
ExtractDestination(scripts[0], destination);
|
||||
address_list.push_back(EncodeParentDestination(destination));
|
||||
}
|
||||
|
||||
// For our manual pattern matching, we don't want the checksum part.
|
||||
auto checksum_char = bitcoin_desc.find('#');
|
||||
if (checksum_char != std::string::npos) {
|
||||
|
|
@ -5204,16 +5217,6 @@ UniValue initpegoutwallet(const JSONRPCRequest& request)
|
|||
assert(len == 33);
|
||||
assert(negatedpubkeybytes.size() == 33);
|
||||
|
||||
UniValue address_list(UniValue::VARR);
|
||||
for (int i = counter; i < counter+3; i++) {
|
||||
std::vector<CScript> scripts;
|
||||
if (!desc->Expand(i, provider, scripts, provider)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Could not generate lookahead addresses with descriptor. This is a bug.");
|
||||
}
|
||||
CTxDestination destination;
|
||||
ExtractDestination(scripts[0], destination);
|
||||
address_list.push_back(EncodeParentDestination(destination));
|
||||
}
|
||||
UniValue pak(UniValue::VOBJ);
|
||||
pak.pushKV("pakentry", "pak=" + HexStr(negatedpubkeybytes) + ":" + HexStr(online_pubkey));
|
||||
pak.pushKV("liquid_pak", HexStr(online_pubkey));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue