add a from flag for miner init

This commit is contained in:
whyrusleeping 2020-08-19 17:34:58 -07:00
parent 885f357c59
commit 2675ffb128

View File

@ -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,