1 // Copyright (c) 2014-2017 The btcsuite developers
2 // Use of this source code is governed by an ISC
3 // license that can be found in the LICENSE file.
10 "github.com/btcsuite/btcd/rpcclient"
14 // Connect to local bitcoin core RPC server using HTTP POST mode.
15 connCfg := &rpcclient.ConnConfig{
16 Host: "localhost:8332",
19 HTTPPostMode: true, // Bitcoin core only supports HTTP POST mode
20 DisableTLS: true, // Bitcoin core does not provide TLS by default
22 // Notice the notification parameter is nil since notifications are
23 // not supported in HTTP POST mode.
24 client, err := rpcclient.New(connCfg, nil)
28 defer client.Shutdown()
30 // Get the current block count.
31 blockCount, err := client.GetBlockCount()
35 log.Printf("Block count: %d", blockCount)