Cant connect Jsonrpc to bitcoin

0 votes

I am using this code to connect jsonrpc to bitcoin:

package main


import "rpc/jsonrpc"

import "fmt"


func main() {

    rc, e := jsonrpc.Dial("tcp", "user:pass@localhost:8332")

    if e != nil {fmt.Print(e);return;}


    var blocks float64

    rc.Call("getblockcount", "", &blocks)

    if e != nil {fmt.Print(e); return;}

    fmt.Print("%f blocks", blocks)

}

When I execute it, I get the following error:

dial tcp user:pass@localhost:8332: too many colons in address user:pass@localhost:8332
Aug 20, 2018 in Blockchain by slayer
• 29,370 points
1,005 views

1 answer to this question.

0 votes

I tried the following code and it worked:

testRequest := `{"jsonrpc": "1.0", "id":"", "method": "help", "params": []}`


request, e := http.NewRequest("POST", brpc.addr, strings.NewReader(testRequest))

request.SetBasicAuth(brpc.user, brpc.pass)


responce, e := brpc.c.Do(request)

// responce.Body has the result
answered Aug 20, 2018 by digger
• 26,740 points

Related Questions In Blockchain

0 votes
1 answer

Docker on mac error message can't connect to Docker endpoint

While CORE_VM_ENDPOINT set to unix:///var/run/docker.sock, please make ...READ MORE

answered Sep 19, 2018 in Blockchain by slayer
• 29,370 points
2,135 views
0 votes
3 answers

Hyperledger fabric: Cant connect peer to channel

Open the hosts file: $ gedit /etc/hosts And add the IP ...READ MORE

answered May 8, 2019 in Blockchain by John
4,378 views
0 votes
1 answer

CryptoCurrency NODE.js Web3 Ethereum - Can't connect to TESTRPC

Your connection is working. To return an ...READ MORE

answered Apr 12, 2022 in Blockchain by Soham
• 9,710 points
663 views
+4 votes
2 answers

I am unable to connect Ganache with Truffle/Npm Dev server. Pls help.

The issue is at CurrentProvider. Give the url ...READ MORE

answered Mar 26, 2018 in Blockchain by Perry
• 17,100 points

edited Oct 11, 2018 by Omkar 2,696 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,740 points
45,218 views
0 votes
1 answer

How do I add multiple recipients for transactions via Blockchain API?

Convert the recipes into JSON objects. x = ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,100 points
885 views
0 votes
1 answer

Bitcoind server connection problem

Be sure to allow your server ip ...READ MORE

answered Aug 23, 2018 in Blockchain by digger
• 26,740 points
948 views
0 votes
1 answer

How to use Proc/lamba returned from a method in Ruby?

You need to remove the colon: list.select(&valid_transaction) The & ...READ MORE

answered Aug 24, 2018 in Blockchain by digger
• 26,740 points
677 views
0 votes
1 answer

Cant Decode Bitcoin Base58 address to byte array

In your for-loop: for (int k = b256.Length ...READ MORE

answered Aug 21, 2018 in Blockchain by digger
• 26,740 points
1,357 views
0 votes
1 answer

Cant install python module for python3.6 to use Jsonrpc for altcoin

Try this  VERSION=0.1 python3 setup.py install and there's also ...READ MORE

answered Sep 7, 2018 in Blockchain by digger
• 26,740 points
910 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP