<p>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 <code>bitcoin-cli</code>'s type conversion table.</p>

<p>At the bottom of the RPC file you added your function to (in this case, <code>src/rpc/blockchain.cpp</code>, 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.</p>

<p>Next, if your command has any arguments which are not strings, open <code>src/rpc/client.cpp</code> and add those arguments to the <code>vRPCConvertParams</code> 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.</p>

CC BY-SA 4.0
2020-05-23T19:05:42.917Z
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:
https://technology.finra.org/code/compile-run-customize-your-own-bitcoin-client.html
ddavi031
CC BY-SA 4.0
2020-05-23T19:15:09.263Z
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
CC BY-SA 4.0
2020-05-24T00:50:47.707Z
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
CC BY-SA 4.0
2020-05-24T08:05:36.363Z
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
CC BY-SA 4.0
2020-05-24T13:58:05.453Z
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
CC BY-SA 4.0
2020-05-24T16:14:08.707Z
`make` compiles it. `make install` compiles and then copies the compiled binaries to an installation location. If you were not directly using the binaries by specifying a path to them (i.e. `src/bitcoind` and `src/bitcoin-cli`), then your system will try to find them by looking them up in the `PATH`. `make install` copies the binaries to a location that is in the `PATH`.
Ava Chow
CC BY-SA 4.0
2020-05-23T16:41:44.700Z
2020-05-23T16:41:44.700Z
Ava Chow
<p>I'm writing a thesis on Bitcoin system and as a part of my assignment i have to explore Bitcoin-core source code.</p>

<p>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 <em>blockchain.cpp</em>.
Problem is that my changes are not visible after i run <em>make</em> and when I run bitcoin-cli -testnet .</p>

<p>I always get:
error code: -32601
error message:
Method not found</p>

<p>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.</p>

<p>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.</p>

<p>Thanks in advance :)</p>

<bitcoin-core><blockchain><bitcoind><bitcoin-cli>
Unable to make custom Bitcoin command
ddavi031
# Unable to make custom Bitcoin command

(Asked by: username_0 on 2020-05-23)

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 :)

**Tags:** bitcoin-core, blockchain, bitcoind, bitcoin-cli


---

## 1 answers

### Answer by username_1 on 2020-05-23. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_0**: 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: https://technology.finra.org/code/compile-run-customize-your-own-bitcoin-client.html  
> **username_0**: 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>  
> **username_1**: 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.  
> **username_0**: 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?  
> **username_0**: Hm, the secret is in calling *sudo make install*, not *make* Now my changes are visible by bitcoin-cli Thank you Andrew username_1 for your support, but do you know maybe the difference between *make* and *make install*?  
> **username_1**: `make` compiles it. `make install` compiles and then copies the compiled binaries to an installation location. If you were not directly using the binaries by specifying a path to them (i.e. `src/bitcoind` and `src/bitcoin-cli`), then your system will try to find them by looking them up in the `PATH`. `make install` copies the binaries to a location that is in the `PATH`.  

---

