Bitcoin Forum

Bitcoin => Bitcoin Discussion => Topic started by: Abiky on October 21, 2016, 12:41:03 AM



Title: How exactly does RPC calls work?
Post by: Abiky on October 21, 2016, 12:41:03 AM
I'm trying to figure out how to send remote RPC calls from within my PC to a remote BTC full node. All I know is that I can set the RPC port, username and password, but when I try to access it via a web browser (by typing its ip address) and put in the login details, I get an error message.

So how exactly does this work? I just want to be able to control a remote full node from my PC just by specifying the commands like: getpeerinfo and dumpprivkey.

Is there something that I may have missed? Please help, as I'm a little confused with this.  ???


Title: Re: How exactly does RPC calls work?
Post by: achow101 on October 21, 2016, 12:45:45 AM
The RPC calls work in the same way other HTTP APIs work where you have to provide data. You must use HTTP post requests. It isn't something you access through the browser.

You can use the bitcoin-cli program which will do everything for you and you use it like you do with the debug console. Or you can get some program that can do HTTP post requests (e.g. curl) and then send a JSON encoded HTTP Post request to call an RPC command. The bitcoind will respond with the output.


Title: Re: How exactly does RPC calls work?
Post by: OgNasty on October 21, 2016, 02:02:19 AM
This video shows how easy it is to use the provided tools with python to handle calls locally.  I don't think using dumpprivkey from remote nodes would be considered the best security practice.

https://www.youtube.com/watch?v=3xAO4K7FC6E


Title: Re: How exactly does RPC calls work?
Post by: franky1 on October 21, 2016, 03:12:07 AM
RPC calls are primarily used for your webserver or other applications to get data from YOUR bitcoin client.
if YOUR bitcoin client is not set up to accept the connection from an application, then it wont work

if you just want to get data from "the web". then use the API calls from some bitcoin explorers such as
blockchain.info/api
https://blockexplorer.com/api-ref
http://blockr.io/documentation/api
but this is not for full wallet access of those websites, just the block data stuff

but as someone said.
opening general access to things like dumpprivkey on YOUR client is bad due to hackers then possibly trying to get at your client to grab your keys.

however i have a strange feeling you are subtly asking this question in the OP, not learn how to set up YOUR client to allow a connection, but how to remotely 'hack' into any client to grab a privkey of a client without them having to open it up to full remote access.

thus subtly asking how to create a hacking tool


Title: Re: How exactly does RPC calls work?
Post by: CrazyCraig on October 21, 2016, 03:32:08 AM
I'm trying to figure out how to send remote RPC calls from within my PC to a remote BTC full node. All I know is that I can set the RPC port, username and password, but when I try to access it via a web browser (by typing its ip address) and put in the login details, I get an error message.

So how exactly does this work? I just want to be able to control a remote full node from my PC just by specifying the commands like: getpeerinfo and dumpprivkey.

Is there something that I may have missed? Please help, as I'm a little confused with this.  ???

Also make sure your firewall isn't blocking the RPC outbound port.


Title: Re: How exactly does RPC calls work?
Post by: Abiky on October 22, 2016, 10:43:52 PM
The RPC calls work in the same way other HTTP APIs work where you have to provide data. You must use HTTP post requests. It isn't something you access through the browser.

You can use the bitcoin-cli program which will do everything for you and you use it like you do with the debug console. Or you can get some program that can do HTTP post requests (e.g. curl) and then send a JSON encoded HTTP Post request to call an RPC command. The bitcoind will respond with the output.

Great! Thanks for the information. I thought that it was something that could be accessed via the web browser by simply adding the necessary details. Just wanted to know more about this since I want to make my own Bitcoin web application.  :)


This video shows how easy it is to use the provided tools with python to handle calls locally.  I don't think using dumpprivkey from remote nodes would be considered the best security practice.

https://www.youtube.com/watch?v=3xAO4K7FC6E

Thanks for the video, mate. It will be of great use to me since I'm very familiar with using Python. My purpose would be more of making a web application using JavaScript that would send RPC calls to the Bitcoin daemon in order to make wallet addresses, deposit BTC, and more (it would be more of like an RPG game). But still, the video above would be very useful for me in case I decide to make a local application from within Python.


@everyone  Thanks guys for all your help. All of this material has greatly helped me into clearing most of my doubts regarding making RPC calls remotely in order to make my own apps with them.  ;)


Title: Re: How exactly does RPC calls work?
Post by: CrazyCraig on October 23, 2016, 04:29:44 AM
The RPC calls work in the same way other HTTP APIs work where you have to provide data. You must use HTTP post requests. It isn't something you access through the browser.

You can use the bitcoin-cli program which will do everything for you and you use it like you do with the debug console. Or you can get some program that can do HTTP post requests (e.g. curl) and then send a JSON encoded HTTP Post request to call an RPC command. The bitcoind will respond with the output.

Great! Thanks for the information. I thought that it was something that could be accessed via the web browser by simply adding the necessary details. Just wanted to know more about this since I want to make my own Bitcoin web application.  :)


This video shows how easy it is to use the provided tools with python to handle calls locally.  I don't think using dumpprivkey from remote nodes would be considered the best security practice.

https://www.youtube.com/watch?v=3xAO4K7FC6E

Thanks for the video, mate. It will be of great use to me since I'm very familiar with using Python. My purpose would be more of making a web application using JavaScript that would send RPC calls to the Bitcoin daemon in order to make wallet addresses, deposit BTC, and more (it would be more of like an RPG game). But still, the video above would be very useful for me in case I decide to make a local application from within Python.


@everyone  Thanks guys for all your help. All of this material has greatly helped me into clearing most of my doubts regarding making RPC calls remotely in order to make my own apps with them.  ;)

Not a problem. If you need help with anything reach out.


Title: Re: How exactly does RPC calls work?
Post by: Sorrowfox on October 23, 2016, 06:08:08 AM
As an analogy, RPC works as a function call. Like a function call, when an RPC is made, the calling arguments are passed to the remote machine and the caller waits for a response to be returned from the remote machine.The client machine makes a procedure call that sends a request which included program number, version number, procedure number & etc to the server and waits. The thread is blocked from processing until either a reply is received, or it times out. When the request arrives, the remote machine calls a dispatch routine that performs the requested service, and sends the reply back to the client procedure. After the RPC call is completed, the client program continues.


Title: Re: How exactly does RPC calls work?
Post by: Abiky on October 24, 2016, 04:31:06 PM
As an analogy, RPC works as a function call. Like a function call, when an RPC is made, the calling arguments are passed to the remote machine and the caller waits for a response to be returned from the remote machine.The client machine makes a procedure call that sends a request which included program number, version number, procedure number & etc to the server and waits. The thread is blocked from processing until either a reply is received, or it times out. When the request arrives, the remote machine calls a dispatch routine that performs the requested service, and sends the reply back to the client procedure. After the RPC call is completed, the client program continues.

Good to know. Thanks a lot mate for this useful explanation about RPC calls. With this, I would be able to make my own Bitcoin apps that would use Bitcoin's functions like creating multi-sig addresses, viewing peer stats, and more. It would be more of like an RPG game where it pays you satoshi after a minimum amount has been reached. You could also choose to buy upgrades for your character, and many more using Bitcoin.

Basically, I find Python a lot easier for this but I would also look into making an online wallet for an altcoin, as most alts have the same RPC commands as Bitcoin.  :)


Title: Re: How exactly does RPC calls work?
Post by: katiecbell on October 25, 2016, 05:23:13 AM
The RPC calls work in the same way other HTTP APIs work where you have to provide data. You must use HTTP post requests. It isn't something you access through the browser.

You can use the bitcoin-cli program which will do everything for you and you use it like you do with the debug console. Or you can get some program that can do HTTP post requests (e.g. curl) and then send a JSON encoded HTTP Post request to call an RPC command. The bitcoind will respond with the output.
Do yo mean we cannot access through browser at all ? This your explanation sounds too technical, I like request you to  put in more possible explanation so that everyone whether tech savvy or not will easily get how RPC calls work...


Title: Re: How exactly does RPC calls work?
Post by: qwik2learn on October 25, 2016, 05:33:39 AM
The RPC calls work in the same way other HTTP APIs work where you have to provide data. You must use HTTP post requests. It isn't something you access through the browser.

You can use the bitcoin-cli program which will do everything for you and you use it like you do with the debug console. Or you can get some program that can do HTTP post requests (e.g. curl) and then send a JSON encoded HTTP Post request to call an RPC command. The bitcoind will respond with the output.

Great! Thanks for the information. I thought that it was something that could be accessed via the web browser by simply adding the necessary details. Just wanted to know more about this since I want to make my own Bitcoin web application.  :)
Hey, what do you know! achow101 has written some code that you could re-use for your project!
https://bitcointalk.org/index.php?topic=1458929.0
It's great stuff, don't miss it!  ;D Maybe you could tip us both for the time that it saved you.  ;)


Title: Re: How exactly does RPC calls work?
Post by: Abiky on October 31, 2016, 06:49:09 PM
Hey, what do you know! achow101 has written some code that you could re-use for your project!
https://bitcointalk.org/index.php?topic=1458929.0
It's great stuff, don't miss it!  ;D Maybe you could tip us both for the time that it saved you.  ;)

Great. Thanks mate! This might be very useful for the little project I'm working on. It will consist of several Raspberry Pis with different power sources in order to determine the most efficient energy solution. Some of those Pis will be used for Bitcoin app development, but the majority would be for crypto currency mining and full nodes for them too. It is good to know about new stuff everyday.  :D

P.S. If I had some BTC, I would send you a tip, but right now I'm all out since I have invested most of the BTC into ICOs.  ;)