Skip to content

Commit

Permalink
Merge pull request #92 from 0chain/createmswallet-threshold-fix
Browse files Browse the repository at this point in the history
Validate that createmswallet threshold is bigger than 0
  • Loading branch information
shaktals authored Feb 24, 2022
2 parents 58ae42b + 30f5313 commit c6ec4d4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/mswallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var createmswalletcmd = &cobra.Command{
MaxSigners := 20 //This is the limitation from MultiSigSC
MinSigners := 2 //This is the limitation from MultiSigSC
fflags := cmd.Flags()
if fflags.Changed("numsigners") == false {
if !fflags.Changed("numsigners") {
ExitWithError("Error: numsigners flag is missing")
}
numsigners, err := cmd.Flags().GetInt("numsigners")
Expand All @@ -37,16 +37,20 @@ var createmswalletcmd = &cobra.Command{
ExitWithError(fmt.Sprintf("Error: too few signers. Minimum numsigners required is %d\n", MinSigners))
}

if fflags.Changed("threshold") == false {
if !fflags.Changed("threshold") {
ExitWithError("Error: threshold flag is missing")
}

threshold, err := cmd.Flags().GetInt("threshold")
if err != nil {
ExitWithError("Error: threshold is not an integer")
}
if threshold > numsigners {
ExitWithError(fmt.Sprintf("Error: given threshold (%d) is too high. Threshold has to be less than or equal to numsigners (%d)\n", threshold, numsigners))
}
if threshold <= 0 {
ExitWithError("Error: threshold should be bigger than 0")
}

testN, err := cmd.Flags().GetBool("testn")
if err != nil {
Expand Down

0 comments on commit c6ec4d4

Please sign in to comment.