From 6d29e192e92ed51beaad3792b33a0b6c5043a00c Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 8 Oct 2020 10:10:58 +0200 Subject: [PATCH] signer/core: don't mismatch reject and no accounts (#21677) * signer/core: don't mismatch reject and zero accounts, fixes #21674 * signer/core: docs --- signer/core/api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/signer/core/api.go b/signer/core/api.go index 6b7d18dfd..43926a75f 100644 --- a/signer/core/api.go +++ b/signer/core/api.go @@ -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()...) } @@ -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 }