You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
917 B

  1. package main
  2. import (
  3. "log"
  4. "github.com/btcsuite/btcrpcclient"
  5. )
  6. func main() {
  7. readConfig("config.json")
  8. // create new client instance
  9. client, err := btcrpcclient.New(&btcrpcclient.ConnConfig{
  10. HTTPPostMode: true,
  11. DisableTLS: true,
  12. Host: config.Host + ":" + config.Port,
  13. User: config.User,
  14. Pass: config.Pass,
  15. }, nil)
  16. if err != nil {
  17. log.Fatalf("error creating new btc client: %v", err)
  18. }
  19. // list accounts
  20. accounts, err := client.ListAccounts()
  21. if err != nil {
  22. log.Fatalf("error listing accounts: %v", err)
  23. }
  24. // iterate over accounts (map[string]btcutil.Amount) and write to stdout
  25. for label, amount := range accounts {
  26. log.Printf("%s: %s", label, amount)
  27. }
  28. explore(client, config.GenesisBlock)
  29. // Get the current block count.
  30. blockCount, err := client.GetBlockCount()
  31. if err != nil {
  32. log.Fatal(err)
  33. }
  34. log.Printf("Block count: %d", blockCount)
  35. }