diff options
Diffstat (limited to 'src/wallet/rpc/addresses.cpp')
-rw-r--r-- | src/wallet/rpc/addresses.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/wallet/rpc/addresses.cpp b/src/wallet/rpc/addresses.cpp index e9b93afc30..17bb6320a1 100644 --- a/src/wallet/rpc/addresses.cpp +++ b/src/wallet/rpc/addresses.cpp @@ -2,6 +2,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <config/bitcoin-config.h> // IWYU pragma: keep + #include <core_io.h> #include <key_io.h> #include <rpc/util.h> @@ -204,9 +206,9 @@ RPCHelpMan listaddressgroupings() addressInfo.push_back(address_book_entry->GetLabel()); } } - jsonGrouping.push_back(addressInfo); + jsonGrouping.push_back(std::move(addressInfo)); } - jsonGroupings.push_back(jsonGrouping); + jsonGroupings.push_back(std::move(jsonGrouping)); } return jsonGroupings; }, @@ -391,6 +393,7 @@ class DescribeWalletAddressVisitor public: const SigningProvider * const provider; + // NOLINTNEXTLINE(misc-no-recursion) void ProcessSubScript(const CScript& subscript, UniValue& obj) const { // Always present: script type and redeemscript @@ -404,9 +407,9 @@ public: // Only when the script corresponds to an address. UniValue subobj(UniValue::VOBJ); UniValue detail = DescribeAddress(embedded); - subobj.pushKVs(detail); + subobj.pushKVs(std::move(detail)); UniValue wallet_detail = std::visit(*this, embedded); - subobj.pushKVs(wallet_detail); + subobj.pushKVs(std::move(wallet_detail)); subobj.pushKV("address", EncodeDestination(embedded)); subobj.pushKV("scriptPubKey", HexStr(subscript)); // Always report the pubkey at the top level, so that `getnewaddress()['pubkey']` always works. @@ -441,6 +444,7 @@ public: return obj; } + // NOLINTNEXTLINE(misc-no-recursion) UniValue operator()(const ScriptHash& scripthash) const { UniValue obj(UniValue::VOBJ); @@ -461,6 +465,7 @@ public: return obj; } + // NOLINTNEXTLINE(misc-no-recursion) UniValue operator()(const WitnessV0ScriptHash& id) const { UniValue obj(UniValue::VOBJ); @@ -485,7 +490,7 @@ static UniValue DescribeWalletAddress(const CWallet& wallet, const CTxDestinatio CScript script = GetScriptForDestination(dest); std::unique_ptr<SigningProvider> provider = nullptr; provider = wallet.GetSolvingProvider(script); - ret.pushKVs(detail); + ret.pushKVs(std::move(detail)); ret.pushKVs(std::visit(DescribeWalletAddressVisitor(provider.get()), dest)); return ret; } @@ -602,7 +607,7 @@ RPCHelpMan getaddressinfo() ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)); UniValue detail = DescribeWalletAddress(*pwallet, dest); - ret.pushKVs(detail); + ret.pushKVs(std::move(detail)); ret.pushKV("ischange", ScriptIsChange(*pwallet, scriptPubKey)); @@ -683,7 +688,7 @@ RPCHelpMan getaddressesbylabel() // which currently is O(1). UniValue value(UniValue::VOBJ); value.pushKV("purpose", _purpose ? PurposeToString(*_purpose) : "unknown"); - ret.pushKVEnd(address, value); + ret.pushKVEnd(address, std::move(value)); } }); @@ -782,9 +787,8 @@ RPCHelpMan walletdisplayaddress() throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); } - if (!pwallet->DisplayAddress(dest)) { - throw JSONRPCError(RPC_MISC_ERROR, "Failed to display address"); - } + util::Result<void> res = pwallet->DisplayAddress(dest); + if (!res) throw JSONRPCError(RPC_MISC_ERROR, util::ErrorString(res).original); UniValue result(UniValue::VOBJ); result.pushKV("address", request.params[0].get_str()); |