add cmd for adding signers to vkh to genesis
This commit is contained in:
parent
ea504dc93b
commit
f86ce88d3d
@ -42,6 +42,7 @@ var genesisCmd = &cli.Command{
|
||||
genesisSetRemainderCmd,
|
||||
genesisSetActorVersionCmd,
|
||||
genesisCarCmd,
|
||||
genesisSetVRKSignersCmd,
|
||||
},
|
||||
}
|
||||
|
||||
@ -581,3 +582,89 @@ var genesisCarCmd = &cli.Command{
|
||||
return err
|
||||
},
|
||||
}
|
||||
|
||||
var genesisSetVRKSignersCmd = &cli.Command{
|
||||
Name: "set-signers",
|
||||
Usage: "",
|
||||
Flags: []cli.Flag{
|
||||
&cli.IntFlag{
|
||||
Name: "threshold",
|
||||
Usage: "change the verifreg signer threshold",
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "signers",
|
||||
Usage: "verifreg signers",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
if cctx.Args().Len() != 1 {
|
||||
return fmt.Errorf("must specify template file")
|
||||
}
|
||||
|
||||
genf, err := homedir.Expand(cctx.Args().First())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var template genesis.Template
|
||||
b, err := ioutil.ReadFile(genf)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("read genesis template: %w", err)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(b, &template); err != nil {
|
||||
return xerrors.Errorf("unmarshal genesis template: %w", err)
|
||||
}
|
||||
|
||||
var signers []address.Address
|
||||
var rootkeyMultisig genesis.MultisigMeta
|
||||
if cctx.IsSet("signers") {
|
||||
for _, s := range cctx.StringSlice("signers") {
|
||||
signer, err := address.NewFromString(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
signers = append(signers, signer)
|
||||
template.Accounts = append(template.Accounts, genesis.Actor{
|
||||
Type: genesis.TAccount,
|
||||
Balance: big.Mul(big.NewInt(50_000), big.NewInt(int64(build.FilecoinPrecision))),
|
||||
Meta: (&genesis.AccountMeta{Owner: signer}).ActorMeta(),
|
||||
})
|
||||
}
|
||||
rootkeyMultisig = genesis.MultisigMeta{
|
||||
Signers: signers,
|
||||
Threshold: 1,
|
||||
VestingDuration: 0,
|
||||
VestingStart: 0,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if cctx.IsSet("threshold") {
|
||||
rootkeyMultisig = genesis.MultisigMeta{
|
||||
Signers: signers,
|
||||
Threshold: cctx.Int("threshold"),
|
||||
VestingDuration: 0,
|
||||
VestingStart: 0,
|
||||
}
|
||||
}
|
||||
|
||||
newVrk := genesis.Actor{
|
||||
Type: genesis.TMultisig,
|
||||
Balance: big.NewInt(0),
|
||||
Meta: rootkeyMultisig.ActorMeta(),
|
||||
}
|
||||
|
||||
template.VerifregRootKey = newVrk
|
||||
|
||||
b, err = json.MarshalIndent(&template, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(genf, b, 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user