1

I'd like to call RPC programmatically, instead of using bitcoin-cli. when I call the function RPCConvertValues(), it always raise error

RPCConvertValues() is defined here : https://github.com/bitcoin/bitcoin/blob/cab94cc07489f704c4b95171b23be0e8025df794/src/rpc/client.cpp#L221

test code are here : https://github.com/bitcoin/bitcoin/blob/46fc4d1a24c88e797d6080336e3828e45e39c3fd/src/test/rpc_tests.cpp#L319 https://github.com/bitcoin/bitcoin/blob/7967104aee055476107dc17265cefc4ae4e75378/src/bitcoin-cli.cpp#L293 https://github.com/bitcoin/bitcoin/blob/eb292af309aa57f3d7998b01307dd4cb91702908/src/qt/rpcconsole.cpp#L302

My test code :

#include <iostream>
#include <rpc/blockchain.cpp>
#include <rpc/request.h>
#include <rpc/client.h>
#include <rpc/util.h>
#include <univalue/include/univalue.h>
#include <interfaces/node.h>

namespace experimental {
    void wait(int seconds) { boost::this_thread::sleep(boost::posix_time::seconds(seconds)); }

    void rpcgetblockhash() {
        wait(30);
        std::cout << "getblockhash RPC CALL!!" << std::endl;

        interfaces::Node* node;
        UniValue params = RPCConvertValues("getblockhash", {"0"}); // occurred error 
    }
}

Occurred error : enter image description here I think that both are same between my function call form and function form of specified link above. I don't know why I'm getting error. can you give some guide?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.