From 2675ffb128aa9721be33d0c7eed416657f9c60ff Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 19 Aug 2020 17:34:58 -0700 Subject: [PATCH] add a from flag for miner init --- cmd/lotus-storage-miner/init.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index 3ebaa4b5a..01569d5e9 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -7,12 +7,13 @@ import ( "encoding/binary" "encoding/json" "fmt" - "github.com/filecoin-project/specs-actors/actors/abi/big" "io/ioutil" "os" "path/filepath" "strconv" + "github.com/filecoin-project/specs-actors/actors/abi/big" + "github.com/docker/go-units" "github.com/google/uuid" "github.com/ipfs/go-datastore" @@ -107,6 +108,10 @@ var initCmd = &cli.Command{ Usage: "set gas premium for initialization messages in AttoFIL", Value: "0", }, + &cli.StringFlag{ + Name: "from", + Usage: "select which address to send actor creation message from", + }, }, Action: func(cctx *cli.Context) error { log.Info("Initializing lotus miner") @@ -631,9 +636,18 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID, return address.Undef, err } + sender := owner + if fromstr := cctx.String("from"); fromstr != "" { + faddr, err := address.NewFromString(fromstr) + if err != nil { + return address.Undef, fmt.Errorf("could not parse from address: %w", err) + } + sender = faddr + } + createStorageMinerMsg := &types.Message{ To: builtin.StoragePowerActorAddr, - From: owner, + From: sender, Value: big.Zero(), Method: builtin.MethodsPower.CreateMiner,