0

I need to interact with blockchain network by API (by Python)? but I have few problems with it.

I have rpcuser, rpcpassword, ip, and port of rpc; api endpoint; and network such as wif_prefix_hex=, address_prefix_hex=, pay_to_script_prefix_hex= and so on. I tried to interact with it by following:

serverURL = rpcUser + ':' + rpcPassword + '@' + rpcIP + ':' + rpcPort
requests.post(serverURL, json={'method': 'getnewaddress'}, )

But I get:

requests.exceptions.InvalidSchema: No connection adapters were found for

How can I solve this?

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

1

You need to specify https:// as part of the URL and for the json= option you had to specify the version number like this { 'jsonrpc': '2.0', 'method': 'getnewaddress', 'id': 47812 }

Also, the call had to include an id number to recover the output or your request would be treated as a notification and no output will be sent from the node as per the JSON-RPC 2.0 specification. I don't think which number it is, is specifically important, unless it matters to bitcoind.

The specification can be found here: https://www.jsonrpc.org/specification

JustKevin
  • 378
  • 3
  • 13