From 587511ba46fdabba85200608c47c218709002941 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 8 Apr 2022 13:27:05 +0200 Subject: [PATCH 1/8] initial wallet support for boost --- cli/node/node.go | 38 +++ cmd/boost/deal_cmd.go | 6 +- cmd/boost/deal_status_cmd.go | 6 +- cmd/boost/helper.go | 63 +++++ cmd/boost/main.go | 1 + cmd/boost/wallet_cmd.go | 476 +++++++++++++++++++++++++++++++++++ cmd/boostx/utils_cmd.go | 2 +- 7 files changed, 589 insertions(+), 3 deletions(-) create mode 100644 cmd/boost/helper.go create mode 100644 cmd/boost/wallet_cmd.go diff --git a/cli/node/node.go b/cli/node/node.go index 855133372..87a2183ad 100644 --- a/cli/node/node.go +++ b/cli/node/node.go @@ -1,8 +1,10 @@ package node import ( + "bytes" "context" "errors" + "fmt" "io/ioutil" "os" "path/filepath" @@ -10,6 +12,7 @@ import ( crand "crypto/rand" "github.com/filecoin-project/boost/lib/keystore" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/wallet" "github.com/libp2p/go-libp2p" @@ -111,3 +114,38 @@ func keyPath(baseDir string) string { func walletPath(baseDir string) string { return filepath.Join(baseDir, "wallet") } + +func (n *Node) GetProviderOrDefaultWallet(ctx context.Context, provided string) (address.Address, error) { + var walletAddr address.Address + if provided == "" { + var err error + walletAddr, err = n.Wallet.GetDefault() + if err != nil { + return address.Address{}, err + } + } else { + w, err := address.NewFromString(provided) + if err != nil { + return address.Address{}, err + } + + addrs, err := n.Wallet.WalletList(ctx) + if err != nil { + return address.Address{}, err + } + + found := false + for _, a := range addrs { + if bytes.Equal(a.Bytes(), w.Bytes()) { + walletAddr = w + found = true + } + } + + if !found { + return address.Address{}, fmt.Errorf("couldn't find wallet %s locally", provided) + } + } + + return walletAddr, nil +} diff --git a/cmd/boost/deal_cmd.go b/cmd/boost/deal_cmd.go index fda958b7e..7c7c5dd28 100644 --- a/cmd/boost/deal_cmd.go +++ b/cmd/boost/deal_cmd.go @@ -83,6 +83,10 @@ var dealFlags = []cli.Flag{ Usage: "whether the deal funds should come from verified client data-cap", Value: true, }, + &cli.StringFlag{ + Name: "wallet", + Usage: "wallet address to be used to initiate the deal", + }, } var dealCmd = &cli.Command{ @@ -134,7 +138,7 @@ func dealCmdAction(cctx *cli.Context, isOnline bool) error { } defer closer() - walletAddr, err := n.Wallet.GetDefault() + walletAddr, err := n.GetProviderOrDefaultWallet(ctx, cctx.String("wallet")) if err != nil { return err } diff --git a/cmd/boost/deal_status_cmd.go b/cmd/boost/deal_status_cmd.go index 3c67dadf4..bef03f6f2 100644 --- a/cmd/boost/deal_status_cmd.go +++ b/cmd/boost/deal_status_cmd.go @@ -35,6 +35,10 @@ var dealStatusCmd = &cli.Command{ Usage: "", Required: true, }, + &cli.StringFlag{ + Name: "wallet", + Usage: "wallet address used to sign the deal proposal", + }, }, Before: before, Action: func(cctx *cli.Context) error { @@ -61,7 +65,7 @@ var dealStatusCmd = &cli.Command{ } defer closer() - walletAddr, err := n.Wallet.GetDefault() + walletAddr, err := n.GetProviderOrDefaultWallet(ctx, cctx.String("wallet")) if err != nil { return err } diff --git a/cmd/boost/helper.go b/cmd/boost/helper.go new file mode 100644 index 000000000..889217932 --- /dev/null +++ b/cmd/boost/helper.go @@ -0,0 +1,63 @@ +package main + +import ( + "fmt" + "io" + "os" + + ufcli "github.com/urfave/cli/v2" +) + +type PrintHelpErr struct { + Err error + Ctx *ufcli.Context +} + +func (e *PrintHelpErr) Error() string { + return e.Err.Error() +} + +func (e *PrintHelpErr) Unwrap() error { + return e.Err +} + +func (e *PrintHelpErr) Is(o error) bool { + _, ok := o.(*PrintHelpErr) + return ok +} + +func ShowHelp(cctx *ufcli.Context, err error) error { + return &PrintHelpErr{Err: err, Ctx: cctx} +} + +type AppFmt struct { + app *ufcli.App + Stdin io.Reader +} + +func NewAppFmt(a *ufcli.App) *AppFmt { + var stdin io.Reader + istdin, ok := a.Metadata["stdin"] + if ok { + stdin = istdin.(io.Reader) + } else { + stdin = os.Stdin + } + return &AppFmt{app: a, Stdin: stdin} +} + +func (a *AppFmt) Print(args ...interface{}) { + fmt.Fprint(a.app.Writer, args...) +} + +func (a *AppFmt) Println(args ...interface{}) { + fmt.Fprintln(a.app.Writer, args...) +} + +func (a *AppFmt) Printf(fmtstr string, args ...interface{}) { + fmt.Fprintf(a.app.Writer, fmtstr, args...) +} + +func (a *AppFmt) Scan(args ...interface{}) (int, error) { + return fmt.Fscan(a.Stdin, args...) +} diff --git a/cmd/boost/main.go b/cmd/boost/main.go index de62013b3..479e1d24c 100644 --- a/cmd/boost/main.go +++ b/cmd/boost/main.go @@ -33,6 +33,7 @@ func main() { dealCmd, dealStatusCmd, offlineDealCmd, + walletCmd, }, } app.Setup() diff --git a/cmd/boost/wallet_cmd.go b/cmd/boost/wallet_cmd.go new file mode 100644 index 000000000..e51551496 --- /dev/null +++ b/cmd/boost/wallet_cmd.go @@ -0,0 +1,476 @@ +package main + +import ( + "bufio" + "encoding/hex" + "encoding/json" + "fmt" + "io/ioutil" + "os" + "strings" + + "github.com/filecoin-project/boost/cli/node" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/lotus/chain/types" + lcli "github.com/filecoin-project/lotus/cli" + "github.com/filecoin-project/lotus/lib/tablewriter" + "github.com/mitchellh/go-homedir" + cli "github.com/urfave/cli/v2" + "golang.org/x/xerrors" +) + +var walletFlags = []cli.Flag{ + &cli.StringFlag{ + Name: "repo", + Usage: "repo directory for Boost client", + Value: "~/.boost-client", + }, +} + +var walletCmd = &cli.Command{ + Name: "wallet", + Usage: "Manage wallets with Boost", + Subcommands: []*cli.Command{ + walletNew, + walletList, + walletBalance, + walletExport, + walletImport, + walletGetDefault, + walletSetDefault, + walletDelete, + }, +} + +var walletNew = &cli.Command{ + Name: "new", + Usage: "Generate a new key of the given type", + ArgsUsage: "[bls|secp256k1 (default secp256k1)]", + Action: func(cctx *cli.Context) error { + ctx := lcli.ReqContext(cctx) + + sdir, err := homedir.Expand(cctx.String("repo")) + if err != nil { + return err + } + + n, err := node.Setup(ctx, sdir) + if err != nil { + return err + } + + t := cctx.Args().First() + if t == "" { + t = "secp256k1" + } + + nk, err := n.Wallet.WalletNew(ctx, types.KeyType(t)) + if err != nil { + return err + } + + fmt.Println(nk.String()) + + return nil + }, +} + +var walletList = &cli.Command{ + Name: "list", + Usage: "List wallet address", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "addr-only", + 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 { + ctx := lcli.ReqContext(cctx) + + sdir, err := homedir.Expand(cctx.String("repo")) + if err != nil { + return err + } + + n, err := node.Setup(ctx, sdir) + if err != nil { + return err + } + + api, closer, err := lcli.GetGatewayAPI(cctx) + if err != nil { + return fmt.Errorf("cant setup gateway connection: %w", err) + } + defer closer() + + afmt := NewAppFmt(cctx.App) + + addrs, err := n.Wallet.WalletList(ctx) + if err != nil { + return err + } + + // Assume an error means no default key is set + def, _ := n.Wallet.GetDefault() + + 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")) + + for _, addr := range addrs { + if cctx.Bool("addr-only") { + afmt.Println(addr.String()) + } else { + a, err := api.StateGetActor(ctx, addr, types.EmptyTSK) + if err != nil { + if !strings.Contains(err.Error(), "actor not found") { + tw.Write(map[string]interface{}{ + "Address": addr, + "Error": err, + }) + continue + } + + a = &types.Actor{ + Balance: big.Zero(), + } + } + + row := map[string]interface{}{ + "Address": addr, + "Balance": types.FIL(a.Balance), + "Nonce": a.Nonce, + } + if addr == def { + 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) + } + } + + if !cctx.Bool("addr-only") { + return tw.Flush(os.Stdout) + } + + return nil + }, +} + +var walletBalance = &cli.Command{ + Name: "balance", + Usage: "Get account balance", + ArgsUsage: "[address]", + Action: func(cctx *cli.Context) error { + ctx := lcli.ReqContext(cctx) + + sdir, err := homedir.Expand(cctx.String("repo")) + if err != nil { + return err + } + + n, err := node.Setup(ctx, sdir) + if err != nil { + return err + } + + api, closer, err := lcli.GetGatewayAPI(cctx) + if err != nil { + return fmt.Errorf("cant setup gateway connection: %w", err) + } + defer closer() + + afmt := NewAppFmt(cctx.App) + + var addr address.Address + if cctx.Args().First() != "" { + addr, err = address.NewFromString(cctx.Args().First()) + } else { + addr, err = n.Wallet.GetDefault() + } + if err != nil { + return err + } + + balance, err := api.WalletBalance(ctx, addr) + if err != nil { + return err + } + + if balance.Equals(types.NewInt(0)) { + afmt.Printf("%s (warning: may display 0 if chain sync in progress)\n", types.FIL(balance)) + } else { + afmt.Printf("%s\n", types.FIL(balance)) + } + + return nil + }, +} + +var walletExport = &cli.Command{ + Name: "export", + Usage: "export keys", + ArgsUsage: "[address]", + Action: func(cctx *cli.Context) error { + ctx := lcli.ReqContext(cctx) + + sdir, err := homedir.Expand(cctx.String("repo")) + if err != nil { + return err + } + + n, err := node.Setup(ctx, sdir) + if err != nil { + return err + } + + afmt := NewAppFmt(cctx.App) + + if !cctx.Args().Present() { + return fmt.Errorf("must specify key to export") + } + + addr, err := address.NewFromString(cctx.Args().First()) + if err != nil { + return err + } + + ki, err := n.Wallet.WalletExport(ctx, addr) + if err != nil { + return err + } + + b, err := json.Marshal(ki) + if err != nil { + return err + } + + afmt.Println(hex.EncodeToString(b)) + return nil + }, +} + +var walletImport = &cli.Command{ + Name: "import", + Usage: "import keys", + ArgsUsage: "[ (optional, will read from stdin if omitted)]", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "format", + Usage: "specify input format for key", + Value: "hex-lotus", + }, + &cli.BoolFlag{ + Name: "as-default", + Usage: "import the given key as your new default key", + }, + }, + Action: func(cctx *cli.Context) error { + ctx := lcli.ReqContext(cctx) + + sdir, err := homedir.Expand(cctx.String("repo")) + if err != nil { + return err + } + + n, err := node.Setup(ctx, sdir) + if err != nil { + return err + } + + var inpdata []byte + if !cctx.Args().Present() || cctx.Args().First() == "-" { + reader := bufio.NewReader(os.Stdin) + fmt.Print("Enter private key: ") + indata, err := reader.ReadBytes('\n') + if err != nil { + return err + } + inpdata = indata + + } else { + fdata, err := ioutil.ReadFile(cctx.Args().First()) + if err != nil { + return err + } + inpdata = fdata + } + + var ki types.KeyInfo + switch cctx.String("format") { + case "hex-lotus": + data, err := hex.DecodeString(strings.TrimSpace(string(inpdata))) + if err != nil { + return err + } + + if err := json.Unmarshal(data, &ki); err != nil { + return err + } + case "json-lotus": + if err := json.Unmarshal(inpdata, &ki); err != nil { + return err + } + case "gfc-json": + var f struct { + KeyInfo []struct { + PrivateKey []byte + SigType int + } + } + if err := json.Unmarshal(inpdata, &f); err != nil { + return xerrors.Errorf("failed to parse go-filecoin key: %s", err) + } + + gk := f.KeyInfo[0] + ki.PrivateKey = gk.PrivateKey + switch gk.SigType { + case 1: + ki.Type = types.KTSecp256k1 + case 2: + ki.Type = types.KTBLS + default: + return fmt.Errorf("unrecognized key type: %d", gk.SigType) + } + default: + return fmt.Errorf("unrecognized format: %s", cctx.String("format")) + } + + addr, err := n.Wallet.WalletImport(ctx, &ki) + if err != nil { + return err + } + + if cctx.Bool("as-default") { + if err := n.Wallet.SetDefault(addr); err != nil { + return fmt.Errorf("failed to set default key: %w", err) + } + } + + fmt.Printf("imported key %s successfully!\n", addr) + return nil + }, +} + +var walletGetDefault = &cli.Command{ + Name: "default", + Usage: "Get default wallet address", + Action: func(cctx *cli.Context) error { + ctx := lcli.ReqContext(cctx) + + sdir, err := homedir.Expand(cctx.String("repo")) + if err != nil { + return err + } + + n, err := node.Setup(ctx, sdir) + if err != nil { + return err + } + + afmt := NewAppFmt(cctx.App) + + addr, err := n.Wallet.GetDefault() + if err != nil { + return err + } + + afmt.Printf("%s\n", addr.String()) + return nil + }, +} + +var walletSetDefault = &cli.Command{ + Name: "set-default", + Usage: "Set default wallet address", + ArgsUsage: "[address]", + Action: func(cctx *cli.Context) error { + ctx := lcli.ReqContext(cctx) + + sdir, err := homedir.Expand(cctx.String("repo")) + if err != nil { + return err + } + + n, err := node.Setup(ctx, sdir) + if err != nil { + return err + } + + if !cctx.Args().Present() { + return fmt.Errorf("must pass address to set as default") + } + + addr, err := address.NewFromString(cctx.Args().First()) + if err != nil { + return err + } + + return n.Wallet.SetDefault(addr) + }, +} + +var walletDelete = &cli.Command{ + Name: "delete", + Usage: "Delete an account from the wallet", + ArgsUsage: "
", + Action: func(cctx *cli.Context) error { + ctx := lcli.ReqContext(cctx) + + sdir, err := homedir.Expand(cctx.String("repo")) + if err != nil { + return err + } + + n, err := node.Setup(ctx, sdir) + if err != nil { + return err + } + + if !cctx.Args().Present() || cctx.NArg() != 1 { + return fmt.Errorf("must specify address to delete") + } + + addr, err := address.NewFromString(cctx.Args().First()) + if err != nil { + return err + } + + return n.Wallet.WalletDelete(ctx, addr) + }, +} diff --git a/cmd/boostx/utils_cmd.go b/cmd/boostx/utils_cmd.go index 03f7ccce0..6d228f6c9 100644 --- a/cmd/boostx/utils_cmd.go +++ b/cmd/boostx/utils_cmd.go @@ -81,7 +81,7 @@ var marketCmd = &cli.Command{ } defer closer() - walletAddr, err := n.Wallet.GetDefault() + walletAddr, err := n.GetProviderOrDefaultWallet(ctx, cctx.String("wallet")) if err != nil { return err } From 8668cc3531d7418bf506d4aa4fae31aaf1977d8e Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 8 Apr 2022 13:35:01 +0200 Subject: [PATCH 2/8] add flag --- cmd/boost/wallet_cmd.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/boost/wallet_cmd.go b/cmd/boost/wallet_cmd.go index e51551496..a0fa8ca66 100644 --- a/cmd/boost/wallet_cmd.go +++ b/cmd/boost/wallet_cmd.go @@ -20,17 +20,16 @@ import ( "golang.org/x/xerrors" ) -var walletFlags = []cli.Flag{ - &cli.StringFlag{ - Name: "repo", - Usage: "repo directory for Boost client", - Value: "~/.boost-client", - }, -} - var walletCmd = &cli.Command{ Name: "wallet", Usage: "Manage wallets with Boost", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "repo", + Usage: "repo directory for Boost client", + Value: "~/.boost-client", + }, + }, Subcommands: []*cli.Command{ walletNew, walletList, @@ -388,8 +387,9 @@ var walletImport = &cli.Command{ } var walletGetDefault = &cli.Command{ - Name: "default", - Usage: "Get default wallet address", + Name: "default", + Usage: "Get default wallet address", + Aliases: []string{"get-default"}, Action: func(cctx *cli.Context) error { ctx := lcli.ReqContext(cctx) From af9ac29a7c1270d6fe6c761dc651fd5cb78f2c27 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 8 Apr 2022 13:36:45 +0200 Subject: [PATCH 3/8] fixup --- cmd/boost/helper.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cmd/boost/helper.go b/cmd/boost/helper.go index 889217932..e1d50dcc7 100644 --- a/cmd/boost/helper.go +++ b/cmd/boost/helper.go @@ -26,10 +26,6 @@ func (e *PrintHelpErr) Is(o error) bool { return ok } -func ShowHelp(cctx *ufcli.Context, err error) error { - return &PrintHelpErr{Err: err, Ctx: cctx} -} - type AppFmt struct { app *ufcli.App Stdin io.Reader From 8c80ea01d83110fb257adb84b6c898fce359b918 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 8 Apr 2022 13:40:34 +0200 Subject: [PATCH 4/8] lint --- cmd/boost/helper.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/cmd/boost/helper.go b/cmd/boost/helper.go index e1d50dcc7..6a16c8376 100644 --- a/cmd/boost/helper.go +++ b/cmd/boost/helper.go @@ -8,24 +8,6 @@ import ( ufcli "github.com/urfave/cli/v2" ) -type PrintHelpErr struct { - Err error - Ctx *ufcli.Context -} - -func (e *PrintHelpErr) Error() string { - return e.Err.Error() -} - -func (e *PrintHelpErr) Unwrap() error { - return e.Err -} - -func (e *PrintHelpErr) Is(o error) bool { - _, ok := o.(*PrintHelpErr) - return ok -} - type AppFmt struct { app *ufcli.App Stdin io.Reader From 008ee6c69819b43c04178205ee70c42b0a9b3208 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 8 Apr 2022 13:41:31 +0200 Subject: [PATCH 5/8] rename --- cli/node/node.go | 2 +- cmd/boost/deal_cmd.go | 2 +- cmd/boost/deal_status_cmd.go | 2 +- cmd/boostx/utils_cmd.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/node/node.go b/cli/node/node.go index 87a2183ad..28353f431 100644 --- a/cli/node/node.go +++ b/cli/node/node.go @@ -115,7 +115,7 @@ func walletPath(baseDir string) string { return filepath.Join(baseDir, "wallet") } -func (n *Node) GetProviderOrDefaultWallet(ctx context.Context, provided string) (address.Address, error) { +func (n *Node) GetProvidedOrDefaultWallet(ctx context.Context, provided string) (address.Address, error) { var walletAddr address.Address if provided == "" { var err error diff --git a/cmd/boost/deal_cmd.go b/cmd/boost/deal_cmd.go index 7c7c5dd28..038fba208 100644 --- a/cmd/boost/deal_cmd.go +++ b/cmd/boost/deal_cmd.go @@ -138,7 +138,7 @@ func dealCmdAction(cctx *cli.Context, isOnline bool) error { } defer closer() - walletAddr, err := n.GetProviderOrDefaultWallet(ctx, cctx.String("wallet")) + walletAddr, err := n.GetProvidedOrDefaultWallet(ctx, cctx.String("wallet")) if err != nil { return err } diff --git a/cmd/boost/deal_status_cmd.go b/cmd/boost/deal_status_cmd.go index bef03f6f2..9ef2d7cea 100644 --- a/cmd/boost/deal_status_cmd.go +++ b/cmd/boost/deal_status_cmd.go @@ -65,7 +65,7 @@ var dealStatusCmd = &cli.Command{ } defer closer() - walletAddr, err := n.GetProviderOrDefaultWallet(ctx, cctx.String("wallet")) + walletAddr, err := n.GetProvidedOrDefaultWallet(ctx, cctx.String("wallet")) if err != nil { return err } diff --git a/cmd/boostx/utils_cmd.go b/cmd/boostx/utils_cmd.go index 6d228f6c9..da6511dbc 100644 --- a/cmd/boostx/utils_cmd.go +++ b/cmd/boostx/utils_cmd.go @@ -81,7 +81,7 @@ var marketCmd = &cli.Command{ } defer closer() - walletAddr, err := n.GetProviderOrDefaultWallet(ctx, cctx.String("wallet")) + walletAddr, err := n.GetProvidedOrDefaultWallet(ctx, cctx.String("wallet")) if err != nil { return err } From 5adc40818574d3bdec09f0fc4b0a02972e2e686f Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 8 Apr 2022 14:03:56 +0200 Subject: [PATCH 6/8] remove market flag --- cmd/boost/wallet_cmd.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/cmd/boost/wallet_cmd.go b/cmd/boost/wallet_cmd.go index a0fa8ca66..77d6cb02c 100644 --- a/cmd/boost/wallet_cmd.go +++ b/cmd/boost/wallet_cmd.go @@ -89,11 +89,6 @@ var walletList = &cli.Command{ Usage: "Output ID addresses", Aliases: []string{"i"}, }, - &cli.BoolFlag{ - Name: "market", - Usage: "Output market balances", - Aliases: []string{"m"}, - }, }, Action: func(cctx *cli.Context) error { ctx := lcli.ReqContext(cctx) @@ -171,12 +166,10 @@ var walletList = &cli.Command{ } } - 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) - } + 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) From b1bc1db74c0b2a511ac52f5903dd9636b62c32b7 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 8 Apr 2022 15:36:48 +0200 Subject: [PATCH 7/8] Update cmd/boost/deal_status_cmd.go Co-authored-by: dirkmc --- cmd/boost/deal_status_cmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/boost/deal_status_cmd.go b/cmd/boost/deal_status_cmd.go index 9ef2d7cea..a394e890c 100644 --- a/cmd/boost/deal_status_cmd.go +++ b/cmd/boost/deal_status_cmd.go @@ -37,7 +37,7 @@ var dealStatusCmd = &cli.Command{ }, &cli.StringFlag{ Name: "wallet", - Usage: "wallet address used to sign the deal proposal", + Usage: "the wallet address that was used to sign the deal proposal", }, }, Before: before, From 9707a0b2d43edc71aad02c916c67d8a51fc19b9a Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 8 Apr 2022 15:39:04 +0200 Subject: [PATCH 8/8] missing wallet flag --- cmd/boostx/utils_cmd.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/boostx/utils_cmd.go b/cmd/boostx/utils_cmd.go index da6511dbc..b84f854e0 100644 --- a/cmd/boostx/utils_cmd.go +++ b/cmd/boostx/utils_cmd.go @@ -49,6 +49,10 @@ var marketCmd = &cli.Command{ Usage: "repo directory for Boost client", Value: "~/.boost-client", }, + &cli.StringFlag{ + Name: "wallet", + Usage: "move balance from this wallet address to its market actor", + }, }, ArgsUsage: "", Before: before,