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,260 points

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,660 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 sure that var/run/docker.sock exists in ...READ MORE

answered Sep 19, 2018 in Blockchain by slayer
• 29,260 points
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 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,090 points

edited Oct 11, 2018 by Omkar 407 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,660 points
0 votes
1 answer
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,660 points
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,660 points
0 votes
1 answer

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

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

answered Sep 7, 2018 in Blockchain by digger
• 26,660 points