Wallet balance should display 0 if address can't be resolved

This commit is contained in:
Aayush Rajasekaran 2020-07-22 21:49:13 -04:00
parent f15a3fbaba
commit 14572aa817

View File

@ -2,6 +2,8 @@ package full
import (
"context"
"github.com/filecoin-project/specs-actors/actors/abi/big"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
"github.com/filecoin-project/lotus/lib/sigs"
@ -37,10 +39,16 @@ func (a *WalletAPI) WalletList(ctx context.Context) ([]address.Address, error) {
func (a *WalletAPI) WalletBalance(ctx context.Context, addr address.Address) (types.BigInt, error) {
var bal types.BigInt
return bal, a.StateManager.WithParentStateTsk(types.EmptyTSK, a.StateManager.WithActor(addr, func(act *types.Actor) error {
err := a.StateManager.WithParentStateTsk(types.EmptyTSK, a.StateManager.WithActor(addr, func(act *types.Actor) error {
bal = act.Balance
return nil
}))
if xerrors.Is(err, init_.ErrAddressNotFound) {
return big.Zero(), nil
} else {
return bal, err
}
}
func (a *WalletAPI) WalletSign(ctx context.Context, k address.Address, msg []byte) (*crypto.Signature, error) {