diff options
author | Harris <brakmic@gmail.com> | 2019-12-09 19:52:12 +0100 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2020-06-02 08:50:36 +0200 |
commit | f4185b26d9b2ff2e86c99cdfe3ad9be62bb6299a (patch) | |
tree | 85912ffe022bbd5fdac43e5d933388f2372e6024 /src/bitcoin-cli.cpp | |
parent | f7c65a33508c4bb8e9ed896e150a4fa529a243e5 (diff) |
cli: create GenerateToAddressRequestHandler class
Diffstat (limited to 'src/bitcoin-cli.cpp')
-rw-r--r-- | src/bitcoin-cli.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e959c4496f..4bcae4d68f 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -286,6 +286,28 @@ public: } }; +/** Process RPC generatetoaddress request. */ +class GenerateToAddressRequestHandler : public BaseRequestHandler +{ +public: + UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) override + { + address_str = args.at(1); + UniValue params{RPCConvertValues("generatetoaddress", args)}; + return JSONRPCRequestObj("generatetoaddress", params, 1); + } + + UniValue ProcessReply(const UniValue &reply) override + { + UniValue result(UniValue::VOBJ); + result.pushKV("address", address_str); + result.pushKV("blocks", reply.get_obj()["result"]); + return JSONRPCReplyObj(result, NullUniValue, 1); + } +protected: + std::string address_str; +}; + /** Process default single requests */ class DefaultRequestHandler: public BaseRequestHandler { public: |