diff options
author | Aurèle Oulès <aurele@oules.com> | 2022-12-15 10:58:14 +0100 |
---|---|---|
committer | Aurèle Oulès <aurele@oules.com> | 2023-01-04 12:31:28 +0100 |
commit | 67e7ba8e1aea58fc864f9bb1fc0e56b70777185e (patch) | |
tree | 75210dfd85f9ad2b9851924eb87431aa480f03b1 /src/wallet | |
parent | a653f4bb1f0630a4b2507c3464909a64c6fca7e3 (diff) |
rpc: Sanitize label name in various RPCs
- importprivkey
- importaddress
- importpubkey
- listtransactions
- listsinceblock
- importmulti
- importdescriptors
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/rpc/backup.cpp | 10 | ||||
-rw-r--r-- | src/wallet/rpc/transactions.cpp | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp index ddf10cae15..6a0f8548f1 100644 --- a/src/wallet/rpc/backup.cpp +++ b/src/wallet/rpc/backup.cpp @@ -142,7 +142,7 @@ RPCHelpMan importprivkey() std::string strSecret = request.params[0].get_str(); std::string strLabel; if (!request.params[1].isNull()) - strLabel = request.params[1].get_str(); + strLabel = LabelFromValue(request.params[1]); // Whether to perform rescan after import if (!request.params[2].isNull()) @@ -235,7 +235,7 @@ RPCHelpMan importaddress() std::string strLabel; if (!request.params[1].isNull()) - strLabel = request.params[1].get_str(); + strLabel = LabelFromValue(request.params[1]); // Whether to perform rescan after import bool fRescan = true; @@ -428,7 +428,7 @@ RPCHelpMan importpubkey() std::string strLabel; if (!request.params[1].isNull()) - strLabel = request.params[1].get_str(); + strLabel = LabelFromValue(request.params[1]); // Whether to perform rescan after import bool fRescan = true; @@ -1163,7 +1163,7 @@ static UniValue ProcessImport(CWallet& wallet, const UniValue& data, const int64 if (internal && data.exists("label")) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Internal addresses should not have a label"); } - const std::string& label = data.exists("label") ? data["label"].get_str() : ""; + const std::string& label = data.exists("label") ? LabelFromValue(data["label"]) : ""; const bool add_keypool = data.exists("keypool") ? data["keypool"].get_bool() : false; // Add to keypool only works with privkeys disabled @@ -1457,7 +1457,7 @@ static UniValue ProcessDescriptorImport(CWallet& wallet, const UniValue& data, c const std::string& descriptor = data["desc"].get_str(); const bool active = data.exists("active") ? data["active"].get_bool() : false; const bool internal = data.exists("internal") ? data["internal"].get_bool() : false; - const std::string& label = data.exists("label") ? data["label"].get_str() : ""; + const std::string& label = data.exists("label") ? LabelFromValue(data["label"]) : ""; // Parse descriptor string FlatSigningProvider keys; diff --git a/src/wallet/rpc/transactions.cpp b/src/wallet/rpc/transactions.cpp index 02a1ac5ea1..844657a71c 100644 --- a/src/wallet/rpc/transactions.cpp +++ b/src/wallet/rpc/transactions.cpp @@ -487,7 +487,7 @@ RPCHelpMan listtransactions() std::optional<std::string> filter_label; if (!request.params[0].isNull() && request.params[0].get_str() != "*") { - filter_label = request.params[0].get_str(); + filter_label.emplace(LabelFromValue(request.params[0])); if (filter_label.value().empty()) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Label argument must be a valid label name or \"*\"."); } @@ -637,7 +637,7 @@ RPCHelpMan listsinceblock() std::optional<std::string> filter_label; if (!request.params[5].isNull()) { - filter_label = request.params[5].get_str(); + filter_label = LabelFromValue(request.params[5]); } int depth = height ? wallet.GetLastBlockHeight() + 1 - *height : -1; |