Skip to content

Commit

Permalink
Merge pull request #10105 from filecoin-project/addr-encode
Browse files Browse the repository at this point in the history
chore:shed:encode address to bytes
  • Loading branch information
magik6k authored Jan 24, 2023
2 parents 4fd81e0 + f03c7a8 commit 4682e8f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cmd/lotus-shed/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ import (

var addressCmd = &cli.Command{
Name: "addr",
Usage: "interact with filecoin addresses",
Subcommands: cli.Commands{
addrDecode,
addrEncode,
},
}

var addrDecode = &cli.Command{
Name: "decode",
Usage: "decode hex bytes into address",
Action: func(cctx *cli.Context) error {
addrHex := cctx.Args().First()
Expand All @@ -39,3 +48,17 @@ var addressCmd = &cli.Command{
return nil
},
}

var addrEncode = &cli.Command{
Name: "encode",
Usage: "encode address to hex bytes",
Action: func(cctx *cli.Context) error {
addr, err := address.NewFromString(cctx.Args().First())
if err != nil {
return err
}

fmt.Printf("%x\n", addr.Bytes())
return nil
},
}

0 comments on commit 4682e8f

Please sign in to comment.