diff --git a/account.go b/account.go index b862353..6c2ec48 100644 --- a/account.go +++ b/account.go @@ -173,7 +173,7 @@ func (a *Account) CurrentAddress() (btcutil.Address, error) { func (a *Account) ListSinceBlock(since, curBlockHeight int32, minconf int) ([]btcjson.ListTransactionsResult, error) { - var txList []btcjson.ListTransactionsResult + txList := []btcjson.ListTransactionsResult{} for _, txRecord := range a.TxStore.Records() { // Transaction records must only be considered if they occur // after the block height since. @@ -208,7 +208,7 @@ func (a *Account) ListTransactions(from, count int) ([]btcjson.ListTransactionsR return nil, err } - var txList []btcjson.ListTransactionsResult + txList := []btcjson.ListTransactionsResult{} records := a.TxStore.Records() lastLookupIdx := len(records) - count @@ -237,7 +237,7 @@ func (a *Account) ListAddressTransactions(pkHashes map[string]struct{}) ( return nil, err } - var txList []btcjson.ListTransactionsResult + txList := []btcjson.ListTransactionsResult{} for _, r := range a.TxStore.Records() { for _, c := range r.Credits() { // We only care about the case where len(addrs) == 1, @@ -278,7 +278,7 @@ func (a *Account) ListAllTransactions() ([]btcjson.ListTransactionsResult, error // Search in reverse order: lookup most recently-added first. records := a.TxStore.Records() - var txList []btcjson.ListTransactionsResult + txList := []btcjson.ListTransactionsResult{} for i := len(records) - 1; i >= 0; i-- { jsonResults, err := records[i].ToJSON(a.name, bs.Height, a.Net()) if err != nil { @@ -295,7 +295,7 @@ func (a *Account) ListAllTransactions() ([]btcjson.ListTransactionsResult, error func (a *Account) DumpPrivKeys() ([]string, error) { // Iterate over each active address, appending the private // key to privkeys. - var privkeys []string + privkeys := []string{} for _, info := range a.Wallet.ActiveAddresses() { // Only those addresses with keys needed. pka, ok := info.(wallet.PubKeyAddress) diff --git a/acctmgr.go b/acctmgr.go index 3eef747..c25db0c 100644 --- a/acctmgr.go +++ b/acctmgr.go @@ -800,7 +800,7 @@ func (am *AccountManager) UnlockWallets(passphrase string) (err error) { // DumpKeys returns all WIF-encoded private keys associated with all // accounts. All wallets must be unlocked for this operation to succeed. func (am *AccountManager) DumpKeys() ([]string, error) { - var keys []string + keys := []string{} for _, a := range am.AllAccounts() { switch walletKeys, err := a.DumpPrivKeys(); err { case wallet.ErrWalletLocked: @@ -845,7 +845,7 @@ func (am *AccountManager) ListSinceBlock(since, curBlockHeight int32, minconf int) ([]btcjson.ListTransactionsResult, error) { // Create and fill a map of account names and their balances. - var txList []btcjson.ListTransactionsResult + txList := []btcjson.ListTransactionsResult{} for _, a := range am.AllAccounts() { txTmp, err := a.ListSinceBlock(since, curBlockHeight, minconf) if err != nil { @@ -901,7 +901,7 @@ func (am *AccountManager) ListUnspent(minconf, maxconf int, filter := len(addresses) != 0 - var results []*btcjson.ListUnspentResult + results := []*btcjson.ListUnspentResult{} for _, a := range am.AllAccounts() { unspent, err := a.TxStore.SortedUnspentOutputs() if err != nil { diff --git a/txstore/json.go b/txstore/json.go index 517ff22..42afde3 100644 --- a/txstore/json.go +++ b/txstore/json.go @@ -29,7 +29,7 @@ import ( func (t *TxRecord) ToJSON(account string, chainHeight int32, net *btcnet.Params) ([]btcjson.ListTransactionsResult, error) { - var results []btcjson.ListTransactionsResult + results := []btcjson.ListTransactionsResult{} if d := t.Debits(); d != nil { r, err := d.ToJSON(account, chainHeight, net) if err != nil {