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`
This commit is contained in:
parent
088bf56f2a
commit
15ea3953f0
@ -55,6 +55,10 @@ var actorSetAddrsCmd = &cli.Command{
|
|||||||
Aliases: []string{"set-addrs"},
|
Aliases: []string{"set-addrs"},
|
||||||
Usage: "set addresses that your miner can be publicly dialed on",
|
Usage: "set addresses that your miner can be publicly dialed on",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "from",
|
||||||
|
Usage: "optionally specify the account to send the message from",
|
||||||
|
},
|
||||||
&cli.Int64Flag{
|
&cli.Int64Flag{
|
||||||
Name: "gas-limit",
|
Name: "gas-limit",
|
||||||
Usage: "set gas limit",
|
Usage: "set gas limit",
|
||||||
@ -117,6 +121,25 @@ var actorSetAddrsCmd = &cli.Command{
|
|||||||
return err
|
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})
|
params, err := actors.SerializeParams(&miner.ChangeMultiaddrsParams{NewMultiaddrs: addrs})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -126,7 +149,7 @@ var actorSetAddrsCmd = &cli.Command{
|
|||||||
|
|
||||||
smsg, err := api.MpoolPushMessage(ctx, &types.Message{
|
smsg, err := api.MpoolPushMessage(ctx, &types.Message{
|
||||||
To: maddr,
|
To: maddr,
|
||||||
From: minfo.Worker,
|
From: fromId,
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
GasLimit: gasLimit,
|
GasLimit: gasLimit,
|
||||||
Method: builtin.MethodsMiner.ChangeMultiaddrs,
|
Method: builtin.MethodsMiner.ChangeMultiaddrs,
|
||||||
|
Loading…
Reference in New Issue
Block a user