Don't pannic on walletDefAddr with no addrs

This commit is contained in:
Łukasz Magiera
2019-07-26 01:26:40 +02:00
parent ccfec98f96
commit 45ddd8e590
2 changed files with 8 additions and 1 deletions
+4
View File
@@ -2,6 +2,7 @@ package impl
import (
"context"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-lotus/api"
"github.com/filecoin-project/go-lotus/chain"
@@ -132,6 +133,9 @@ func (a *FullNodeAPI) WalletDefaultAddress(ctx context.Context) (address.Address
if err != nil {
return address.Undef, err
}
if len(addrs) == 0 {
return address.Undef, xerrors.New("no addresses in wallet")
}
// TODO: store a default address in the config or 'wallet' portion of the repo
return addrs[0], nil