refactor: use new format CPCCommand for rpc/coinjoin

This commit is contained in:
Konstantin Akimov 2024-03-13 18:04:50 +07:00 committed by pasta
parent 0e1a31159f
commit d0163543d9
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -21,9 +21,9 @@
#include <univalue.h> #include <univalue.h>
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
static UniValue coinjoin(const JSONRPCRequest& request) static RPCHelpMan coinjoin()
{ {
RPCHelpMan{"coinjoin", return RPCHelpMan{"coinjoin",
"\nAvailable commands:\n" "\nAvailable commands:\n"
" start - Start mixing\n" " start - Start mixing\n"
" stop - Stop mixing\n" " stop - Stop mixing\n"
@ -33,8 +33,8 @@ static UniValue coinjoin(const JSONRPCRequest& request)
}, },
RPCResults{}, RPCResults{},
RPCExamples{""}, RPCExamples{""},
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
if (!wallet) return NullUniValue; if (!wallet) return NullUniValue;
@ -83,10 +83,12 @@ static UniValue coinjoin(const JSONRPCRequest& request)
} }
return "Unknown command, please see \"help coinjoin\""; return "Unknown command, please see \"help coinjoin\"";
},
};
} }
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
static UniValue getpoolinfo(const JSONRPCRequest& request) static RPCHelpMan getpoolinfo()
{ {
throw std::runtime_error( throw std::runtime_error(
RPCHelpMan{"getpoolinfo", RPCHelpMan{"getpoolinfo",
@ -97,9 +99,9 @@ static UniValue getpoolinfo(const JSONRPCRequest& request)
.ToString()); .ToString());
} }
static UniValue getcoinjoininfo(const JSONRPCRequest& request) static RPCHelpMan getcoinjoininfo()
{ {
RPCHelpMan{"getcoinjoininfo", return RPCHelpMan{"getcoinjoininfo",
"Returns an object containing an information about CoinJoin settings and state.\n", "Returns an object containing an information about CoinJoin settings and state.\n",
{}, {},
{ {
@ -143,8 +145,8 @@ static UniValue getcoinjoininfo(const JSONRPCRequest& request)
HelpExampleCli("getcoinjoininfo", "") HelpExampleCli("getcoinjoininfo", "")
+ HelpExampleRpc("getcoinjoininfo", "") + HelpExampleRpc("getcoinjoininfo", "")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
const NodeContext& node = EnsureAnyNodeContext(request.context); const NodeContext& node = EnsureAnyNodeContext(request.context);
@ -173,7 +175,10 @@ static UniValue getcoinjoininfo(const JSONRPCRequest& request)
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
return obj; return obj;
},
};
} }
void RegisterCoinJoinRPCCommands(CRPCTable &t) void RegisterCoinJoinRPCCommands(CRPCTable &t)
{ {
// clang-format off // clang-format off