LOSTMONKEY
LOSTMONKEY

Reputation: 11

How to use params'Address' in package 'github.com/btcsuite/btcd/rpcclient'?

When I'm using the rpcclient to get a new address for the account 'default',running the code below.

client.WalletPassphrase("test1",600)
address,err:=client.GetNewAddress("default")
addresses,err :=client.GetAddressesByAccount("default")
fmt.Println(address)
fmt.Println(addresses)

The output is

<nil>
[]

When I use the command line "btcctl --simnet --rpcuser=rpcuser --rpcpass=rpcpass --wallet getaddressesbyaccount default".It actually output the addresses.

btcctl --simnet --rpcuser=rpcuser --rpcpass=rpcpass --wallet getaddressesbyaccount default
[
  "SY2R4vpLPvucTC4MZX1FEEAdX917FZps1H",
  "SfBUHVbQ2FRqWPe9wHJuJx2yUstHgRbyBi",
  "SehRVnJnhqQ8QeRBgB3B92WZTGo3s9hyCi",
  "SUPkJTmx9EjiSMb6qsoSmjShzrejEkhjgn",
  "SXu8VAv1cKqC5dkJqredVuhzgzD8QVQvQt",
  "SXm73AFZfMqUpCUvEwjdhFxDAwFyD3WVfZ",
  "SgN9K7kEsvWgpSzaP4ZZTYaomQfLyYqdkF",
  "SUKk1E1JR7wGNTdzLtkb7xJmWN8UgAGdH8",
  "SSqpybNox5qXwsDcax8xnA3JqaUqYEzzTq",
  "SNpyvoZSEHudpBC4bogkbySioh6HddpEie",
  "SimTTUz59RytXsXpTGYwaCqgomiGY8egpo",
  "SW9vY6YfJYtHspqVfpijyoi548XXqfrHtt",
  "SXJXnLyxYwL2BG8pcAZgW4HCB5ZVCrsS3G",
  "SRna6gpPf6bqdfvrmCZz5dzfU9qNbnMZvF",
  "SZTUE5WK4EPnF9899a8p5htjpdK9ocN16d",
  "Sk2CH4gy9Jhv1wW5YwZzgZmNPgPoHdeYML",
  "SkBZ2bTdtYykfE7fSRUc3vAM6w1ub3vTbq"
]

So how can I get the these addresses in my golang function?

Upvotes: 0

Views: 151

Answers (1)

Yuseferi
Yuseferi

Reputation: 8710

I would recommand you in each step check the error and log it to see what is the exact error:

( do not forget to import log)

something like the following code could help you what is the error.

client.WalletPassphrase("test1",600)
address,err:=client.GetNewAddress("default")
if err != nil {
  log.Fatal(err)
}
addresses,err :=client.GetAddressesByAccount("default")
if err != nil {
  log.Fatal(err)
}
fmt.Println(address)
fmt.Println(addresses)

Upvotes: 0

Related Questions