rpc: ParsePathBIP32 helper

This commit is contained in:
Sjors Provoost
2025-06-16 15:00:55 +02:00
parent e36c4b76e1
commit 0ab61caafd
2 changed files with 13 additions and 0 deletions

View File

@@ -20,6 +20,7 @@
#include <tinyformat.h>
#include <uint256.h>
#include <univalue.h>
#include <util/bip32.h>
#include <util/check.h>
#include <util/result.h>
#include <util/strencodings.h>
@@ -1379,6 +1380,15 @@ std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, Fl
return ret;
}
std::vector<uint32_t> ParsePathBIP32(const std::string& path)
{
std::vector<uint32_t> out;
if (!ParseHDKeypath(path, out)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid BIP32 keypath");
}
return out;
}
/** Convert a vector of bilingual strings to a UniValue::VARR containing their original untranslated values. */
[[nodiscard]] static UniValue BilingualStringsToUniValue(const std::vector<bilingual_str>& bilingual_strings)
{

View File

@@ -156,6 +156,9 @@ std::pair<int64_t, int64_t> ParseDescriptorRange(const UniValue& value);
/** Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range of 1000. */
std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, FlatSigningProvider& provider, bool expand_priv = false);
//! Parse BIP32 path
std::vector<uint32_t> ParsePathBIP32(const std::string& path);
/**
* Serializing JSON objects depends on the outer type. Only arrays and
* dictionaries can be nested in json. The top-level outer type is "NONE".