[Question] RPCConvertValues() call error #17644

issue hyunsooda opened this issue on December 1, 2019
  1. hyunsooda commented at 4:15 PM on December 1, 2019: none

    [Question]

    Hi, 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 : <img width="1375" alt="스크린샷 2019-12-02 오전 1 11 05" src="https://user-images.githubusercontent.com/12508269/69916639-b576b500-14a0-11ea-8dc8-a4cad816e31c.png">

    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?

  2. fanquake commented at 4:19 PM on December 1, 2019: member

    This issue tracker if for technical issues related only to Bitcoin Core, and should not be used for general programming questions / support. You might want to try the Bitcoin Stack Exchange instead.

  3. fanquake closed this on Dec 1, 2019

  4. hyunsooda commented at 6:38 PM on December 1, 2019: none

    I'm sorry. I didn't know about policy.

    CBlockIndex* pblockindex = ::ChainActive()[0]; UniValue blockhash = pblockindex->GetBlockHash().GetHex(); std::cout << blockhash.get_str() << std::endl;

    I found some other method to solve after analyzing code flow and leave it above for some people that may face to similar problem.

    I think that compatibility between version of boost library and Mac OS may be correlated, especially when pass vector parameter into function.

  5. MarcoFalke locked this on Dec 16, 2021
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-26 06:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me