Skip to content

Commit

Permalink
Merge pull request #4555 from filecoin-project/feat/walletlist-id-market
Browse files Browse the repository at this point in the history
wallet list: Add market balance and ID address flags
  • Loading branch information
magik6k authored Oct 23, 2020
2 parents 7d9e8f9 + 9caa6ae commit 623ffeb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cli/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ var walletList = &cli.Command{
Usage: "Only print addresses",
Aliases: []string{"a"},
},
&cli.BoolFlag{
Name: "id",
Usage: "Output ID addresses",
Aliases: []string{"i"},
},
&cli.BoolFlag{
Name: "market",
Usage: "Output market balances",
Aliases: []string{"m"},
},
},
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
Expand All @@ -98,7 +108,10 @@ var walletList = &cli.Command{

tw := tablewriter.New(
tablewriter.Col("Address"),
tablewriter.Col("ID"),
tablewriter.Col("Balance"),
tablewriter.Col("Market(Avail)"),
tablewriter.Col("Market(Locked)"),
tablewriter.Col("Nonce"),
tablewriter.Col("Default"),
tablewriter.NewLineCol("Error"))
Expand Down Expand Up @@ -131,6 +144,23 @@ var walletList = &cli.Command{
row["Default"] = "X"
}

if cctx.Bool("id") {
id, err := api.StateLookupID(ctx, addr, types.EmptyTSK)
if err != nil {
row["ID"] = "n/a"
} else {
row["ID"] = id
}
}

if cctx.Bool("market") {
mbal, err := api.StateMarketBalance(ctx, addr, types.EmptyTSK)
if err == nil {
row["Market(Avail)"] = types.FIL(types.BigSub(mbal.Escrow, mbal.Locked))
row["Market(Locked)"] = types.FIL(mbal.Locked)
}
}

tw.Write(row)
}
}
Expand Down

0 comments on commit 623ffeb

Please sign in to comment.