Skip to content

Commit

Permalink
signer/core: don't mismatch reject and no accounts (ethereum#21677)
Browse files Browse the repository at this point in the history
* signer/core: don't mismatch reject and zero accounts, fixes ethereum#21674

* signer/core: docs
  • Loading branch information
holiman authored Oct 8, 2020
1 parent 015e789 commit 6d29e19
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions signer/core/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ func (api *SignerAPI) startUSBListener() {
// List returns the set of wallet this signer manages. Each wallet can contain
// multiple accounts.
func (api *SignerAPI) List(ctx context.Context) ([]common.Address, error) {
var accs []accounts.Account
var accs = make([]accounts.Account, 0)
// accs is initialized as empty list, not nil. We use 'nil' to signal
// rejection, as opposed to an empty list.
for _, wallet := range api.am.Wallets() {
accs = append(accs, wallet.Accounts()...)
}
Expand All @@ -393,13 +395,11 @@ func (api *SignerAPI) List(ctx context.Context) ([]common.Address, error) {
}
if result.Accounts == nil {
return nil, ErrRequestDenied

}
addresses := make([]common.Address, 0)
for _, acc := range result.Accounts {
addresses = append(addresses, acc.Address)
}

return addresses, nil
}

Expand Down

0 comments on commit 6d29e19

Please sign in to comment.