Author

Topic: Why is it empty when sending rpc via curl? (Read 175 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
October 11, 2022, 04:51:04 AM
#10
--snip--
The funny thing is that I don't know where to get them from.(
IP I took from the seeds
In curl, I specify any login and password, but I don’t know where to get which one is needed (

FYI, if that node isn't owned by you or the owner doesn't give RPC credential to you, your only option is connect to that node using P2P protocol[1][2]. But you only can get limited data such as transaction, block and block header.

You also have this file generator: https://jlopp.github.io/bitcoin-core-config-generator/ I have not used it so I can't comment on how accurate it is, but I know people who have used it that say it does generate valid files.

I used it and it generate valid/accurate config file, but i used it 1-2 years ago.



[1] https://developer.bitcoin.org/devguide/p2p_network.html
[2] https://en.bitcoin.it/wiki/Protocol_documentation#Message_types
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
October 11, 2022, 12:47:40 AM
#9
Note that you can also rent your own Bitcoin node with JSON-RPC access from GetBlock. Never used them myself, but they seem pretty good.
legendary
Activity: 3500
Merit: 6320
Crypto Swap Exchange
October 10, 2022, 03:01:15 PM
#8
You should only talk to your own nodes through RPC. In the conf file you need to specify a user and password and IP range for RPC to talk to.

If you need to pull other information there are various services that allow for API calls, but since access to RPC more or less means you have access to the wallet that is there you are probably not going to be able to find anyplace that allows remote calls. It's just basic bitcoin security and security in general.

-Dave




Can you link to documentation and examples?

Take a look at: https://riptutorial.com/bitcoin/example/26000/node-configuration that more or less gives all the options that are available in the conf file.

You also have this file generator: https://jlopp.github.io/bitcoin-core-config-generator/ I have not used it so I can't comment on how accurate it is, but I know people who have used it that say it does generate valid files.

Keep in mind when running this against your own node that it does have to be fully synced for some things. I know some (most?) commands will not work until your node has finished the IBD and if you re-start it until it finishes whatever housekeeping it has to do at startup.

What are you trying to do anyway?

-Dave

hero member
Activity: 910
Merit: 5935
not your keys, not your coins!
October 10, 2022, 02:07:29 PM
#7
Then how to be? Out of 100 ip 6-8 ips give out 401 and the rest are not working at all
Wait, why are you trying to connect to 100 IP addresses? Did you get IP addresses of random Bitcoin nodes and try to query them? That doesn't work. Especially since they most likely do not expose their RPC interface to the internet. That would be highly insecure.

Do you even have your own Bitcoin node?
legendary
Activity: 3500
Merit: 6320
Crypto Swap Exchange
October 10, 2022, 12:05:53 PM
#6
You should only talk to your own nodes through RPC. In the conf file you need to specify a user and password and IP range for RPC to talk to.

If you need to pull other information there are various services that allow for API calls, but since access to RPC more or less means you have access to the wallet that is there you are probably not going to be able to find anyplace that allows remote calls. It's just basic bitcoin security and security in general.

-Dave


member
Activity: 107
Merit: 168
Security Researcher and Writer
October 10, 2022, 11:14:01 AM
#5

Exactly, look at HTTP status code. 401 means Unauthorized, you need to supply valid username and password to be able to use RPC interface for that node.
The funny thing is that I don't know where to get them from.(
IP I took from the seeds
In curl, I specify any login and password, but I don’t know where to get which one is needed (

Why should you have the username/password if the node is not yours? Anyone can start a node, and can restrict the json API interface.
member
Activity: 107
Merit: 168
Security Researcher and Writer
October 10, 2022, 10:59:42 AM
#4

Exactly, look at HTTP status code. 401 means Unauthorized, you need to supply valid username and password to be able to use RPC interface for that node.
member
Activity: 107
Merit: 168
Security Researcher and Writer
October 10, 2022, 10:50:17 AM
#3
Why is it empty when sending rpc via curl?
Code:
curl --user x:x --data-binary '{"jsonrpc":"1.0","id":"curltest","method":"getrpcinfo","params":[]}' -H 'content-type:text/plain;' http://95.216.35.227:8332/

Add flag --verbose to see the actual response from the server. You're sending a wrong username or password.

Code:
*   Trying 95.216.35.227...
* TCP_NODELAY set
* Connected to 95.216.35.227 (95.216.35.227) port 8332 (#0)
> POST / HTTP/1.1
> Host: 95.216.35.227:8332
> User-Agent: curl/7.52.1
> Accept: */*
> content-type:text/plain;
> Content-Length: 67
>
* upload completely sent off: 67 out of 67 bytes
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Basic realm="jsonrpc"
< Date: Mon, 10 Oct 2022 15:49:26 GMT
< Content-Length: 0
< Content-Type: text/html; charset=ISO-8859-1
<
* Curl_http_done: called premature == 0
* Connection #0 to host 95.216.35.227 left intact
full member
Activity: 267
Merit: 109
October 10, 2022, 10:49:18 AM
#2
Why is it empty when sending rpc via curl?
Code:
curl --user x:x --data-binary '{"jsonrpc":"1.0","id":"curltest","method":"getrpcinfo","params":[]}' -H 'content-type:text/plain;' http://95.216.35.227:8332/

Either 1) The listed IP does not have the RPC port exposed, or 2) You are trying to do this to your own node from within NAT.
newbie
Activity: 24
Merit: 2
October 10, 2022, 10:35:40 AM
#1
None
Jump to: