Skip to content

Commit

Permalink
Merge pull request #4521 from filecoin-project/feat/fix-shed-ledger-list
Browse files Browse the repository at this point in the history
Fix lotus-shed ledger list
  • Loading branch information
magik6k authored Oct 22, 2020
2 parents c17e8e7 + f0d966a commit f9723ca
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cmd/lotus-shed/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"strings"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
"github.com/urfave/cli/v2"
ledgerfil "github.com/whyrusleeping/ledger-filecoin-go"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -76,15 +76,22 @@ var ledgerListAddressesCmd = &cli.Command{
}

if cctx.Bool("print-balances") && api != nil { // api check makes linter happier
b, err := api.WalletBalance(ctx, addr)
a, err := api.StateGetActor(ctx, addr, types.EmptyTSK)
if err != nil {
return xerrors.Errorf("getting balance: %w", err)
if strings.Contains(err.Error(), "actor not found") {
a = nil
} else {
return err
}
}
if !b.IsZero() {
end = i + 21 // BIP32 spec, stop after 20 empty addresses

balance := big.Zero()
if a != nil {
balance = a.Balance
end = i + 20 + 1
}

fmt.Printf("%s %s %s\n", addr, printHDPath(p), types.FIL(b))
fmt.Printf("%s %s %s\n", addr, printHDPath(p), types.FIL(balance))
} else {
fmt.Printf("%s %s\n", addr, printHDPath(p))
}
Expand Down

0 comments on commit f9723ca

Please sign in to comment.