cli/wallet: request candidate registration price

Hardcoding 1000 is wrong. Inspired by neo-project/neo-node#788.
This commit is contained in:
Roman Khimov 2021-07-21 12:25:42 +03:00
parent 5bdcd4c241
commit 5fbb60a9ed

View file

@ -90,7 +90,7 @@ func newValidatorCommands() []cli.Command {
} }
func handleRegister(ctx *cli.Context) error { func handleRegister(ctx *cli.Context) error {
return handleCandidate(ctx, "registerCandidate", 1001*100000000) // registering costs 1000 GAS return handleCandidate(ctx, "registerCandidate", 100000000) // 1 additional GAS.
} }
func handleUnregister(ctx *cli.Context) error { func handleUnregister(ctx *cli.Context) error {
@ -122,6 +122,14 @@ func handleCandidate(ctx *cli.Context, method string, sysGas int64) error {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
if sysGas >= 0 {
regPrice, err := c.GetCandidateRegisterPrice()
if err != nil {
return cli.NewExitError(err, 1)
}
sysGas += regPrice
}
gas := flags.Fixed8FromContext(ctx, "gas") gas := flags.Fixed8FromContext(ctx, "gas")
neoContractHash, err := c.GetNativeContractHash(nativenames.Neo) neoContractHash, err := c.GetNativeContractHash(nativenames.Neo)
if err != nil { if err != nil {