SHARE
TWEET

Untitled

a guest Apr 20th, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "log"
  5.     "fmt"
  6.     rpcclient "github.com/stevenroose/go-bitcoin-core-rpc"
  7. )
  8.  
  9. func main() {
  10.     // Connect to local bitcoin core RPC server using HTTP POST mode.
  11.     connCfg := &rpcclient.ConnConfig{
  12.         Host: "192.168.0.123:8332",
  13.         User: "parser",
  14.         Pass: "qwsx123",
  15.     }
  16.     // Notice the notification parameter is nil since notifications are
  17.     // not supported in HTTP POST mode.
  18.     client, err := rpcclient.New(connCfg)
  19.     if err != nil {
  20.         log.Fatal(err)
  21.     }
  22.     defer client.Shutdown()
  23.  
  24.     // Get the current block count.
  25.     blockCount, err := client.GetBlockCount()
  26.     if err != nil {
  27.         log.Fatal(err)
  28.     }
  29.     log.Printf("Block count: %d", blockCount)
  30.  
  31.     blockhash,_ := client.GetBlockHash(2)
  32.     blockverbose,_ := client.GetBlockVerbose(blockhash)
  33.     Log.Printf("%d",blockverbose)
  34.  
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top