From 15ea3953f09311d1587d1c3291013771ca7ba3e7 Mon Sep 17 00:00:00 2001 From: Phi Date: Wed, 31 Aug 2022 18:42:24 +0200 Subject: [PATCH] Option to specify --from msg sender Adds the option to specify the account to send the message from in the `lotus-miner actor set-addrs` --- cmd/lotus-miner/actor.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/cmd/lotus-miner/actor.go b/cmd/lotus-miner/actor.go index ba7c944d7..b3e7df4dc 100644 --- a/cmd/lotus-miner/actor.go +++ b/cmd/lotus-miner/actor.go @@ -55,6 +55,10 @@ var actorSetAddrsCmd = &cli.Command{ Aliases: []string{"set-addrs"}, Usage: "set addresses that your miner can be publicly dialed on", Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "from", + Usage: "optionally specify the account to send the message from", + }, &cli.Int64Flag{ Name: "gas-limit", Usage: "set gas limit", @@ -117,6 +121,25 @@ var actorSetAddrsCmd = &cli.Command{ return err } + fromAddr := minfo.Worker + if from := cctx.String("from"); from != "" { + addr, err := address.NewFromString(from) + if err != nil { + return err + } + + fromAddr = addr + } + + fromId, err := api.StateLookupID(ctx, fromAddr, types.EmptyTSK) + if err != nil { + return err + } + + if !isController(minfo, fromId) { + return xerrors.Errorf("sender isn't a controller of miner: %s", fromId) + } + params, err := actors.SerializeParams(&miner.ChangeMultiaddrsParams{NewMultiaddrs: addrs}) if err != nil { return err @@ -126,7 +149,7 @@ var actorSetAddrsCmd = &cli.Command{ smsg, err := api.MpoolPushMessage(ctx, &types.Message{ To: maddr, - From: minfo.Worker, + From: fromId, Value: types.NewInt(0), GasLimit: gasLimit, Method: builtin.MethodsMiner.ChangeMultiaddrs,