btcsuite / btcwallet

A secure bitcoin wallet daemon written in Go (golang)
ISC License
1.15k stars 590 forks source link

listaccounts only checks balances for KeyScopeBIP0044 addresses #881

Open 1F47E opened 1 year ago

1F47E commented 1 year ago

I noticed that the listaccounts command is using only the KeyScopeBIP0044 scope when returning a list of accounts and their balances. Given that there are multiple key scopes defined (i.e., KeyScopeBIP0049Plus, KeyScopeBIP0084),

I wonder if listaccounts command should check balances for all of these key types.

In the example below I have some balance on bech32 addresses and 0 in legacy.

btcctl --wallet listaccounts

{
  "default": 0,
}

Calculated not correctly via

results, err := w.AccountBalances(waddrmgr.KeyScopeBIP0044, int32(*cmd.MinConf))

btcctl --wallet getbalance default

0.10720198

calculated correctly via

bals, err := w.CalculateAccountBalances(account, int32(*cmd.MinConf))

Question:

Is the current implementation as intended, or should the command be checking account balances across all key scopes?

If this is not intended behavior, I would be interested in contributing a pull request to address this.