I'm writing a thesis on Bitcoin system and as a part of my assignment i have to explore Bitcoin-core source code.

I 've downloaded the code, compiled it and manage to run it. However, I wanted to make a trivial change to the code and add some simple custom command as part of blockchain.cpp. Problem is that my changes are not visible after i run make and when I run bitcoin-cli -testnet .

I always get: error code: -32601 error message: Method not found

Also, i tried commenting out one already functional method and tried to run bitcoin-cli and calling that function and it runs successfully. NOTE: command "make" runs smoothly and it does detect errors if there are any.

Can someone explain me what is a proper way to make change to bitcoin-core? I am not planning to push any of those changes to master branch, I'm just interested in experimenting with code.

Thanks in advance :)

1 Answer 1


To add a new RPC, you need to write the function the implements it's action, add the function to the dispatch table, and update bitcoin-cli's type conversion table.

At the bottom of the RPC file you added your function to (in this case, src/rpc/blockchain.cpp, you will see a table that has all of the RPCs in that file as well as some extra information about them like category, name, and argument names. Add your new RPC to that table.

Next, if your command has any arguments which are not strings, open src/rpc/client.cpp and add those arguments to the vRPCConvertParams list there. In that list, you give it the RPC name, the index of the argument that needs to be converted, and the name of that argument.

  • Hello, first of all, thank you for your answer. Second of all i think i did all you mentioned. To be more specific, i followed the steps on this link: technology.finra.org/code/…
    – ddavi031
    May 23, 2020 at 19:05
  • To be more precise, I added function with randomName to blockchain.cpp, i added it to vector command[] at the bottom of the file and i added it into client.cpp It seems to me, when i call "make" upon repo bitcoin-master, changes are visible (because i had some errors), but when i call bitcoin-cli -testnet methodName, function is invisible. Thats why i tried to comment out, for example, funcion "getblockhash" from blockchain.cpp and from client.cpp just to see are my changes visible. Command make was successful, but i was still able to call bitcoin-cli -testnet getblockhash <randomNumber>
    – ddavi031
    May 23, 2020 at 19:15
  • Did you restart bitcoind after recompiling? The commands are part of bitcoind, not bitcoin-cli. bitcoin-cli is merely a way to access the RPC interface of bitcoind via the command line. It doesn't actually have the command implemented in it.
    – Ava Chow
    May 24, 2020 at 0:50
  • Thank you a lot Andrew for your support, but.. After my change, i enter: bitcoind -testnet --daemon which results with: Bitcoin Core starting When i make a change in the middle of running BitcoinCore, firstly i type: bitcoin-cli -testnet stop Which results: Bitcoin Core stopping And then type command for starting bitcoin again Am i doing something wrong?
    – ddavi031
    May 24, 2020 at 8:05
  • Hm, the secret is in calling sudo make install, not make Now my changes are visible by bitcoin-cli Thank you Andrew Chow for your support, but do you know maybe the difference between make and make install?
    – ddavi031
    May 24, 2020 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.