Skip to content

Commit

Permalink
fix: tx verify was using blank env variable as a default instead of t…
Browse files Browse the repository at this point in the history
…he built in default. TX verification works now
  • Loading branch information
randomshinichi committed May 23, 2019
1 parent 534342a commit 2ccd333
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cmd/root.go
Expand Up @@ -63,8 +63,8 @@ func init() {
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags, which, if defined here,
// will be global for your application.
RootCmd.PersistentFlags().StringVarP(&aeternity.Config.Node.URL, "external-api", "u", viper.GetString("EXTERNAL_API"), "node external API endpoint")
RootCmd.PersistentFlags().StringVarP(&aeternity.Config.Node.NetworkID, "network-id", "n", viper.GetString("NETWORK_ID"), "network ID for custom private net")
RootCmd.PersistentFlags().StringVarP(&aeternity.Config.Node.URL, "external-api", "u", aeternity.Config.Node.URL, "node external API endpoint")
RootCmd.PersistentFlags().StringVarP(&aeternity.Config.Node.NetworkID, "network-id", "n", aeternity.Config.Node.NetworkID, "network ID for custom private net")
RootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "enable debug")
RootCmd.PersistentFlags().BoolVar(&aeternity.Config.Tuning.OutputFormatJSON, "json", false, "print output in json format")
}
21 changes: 14 additions & 7 deletions cmd/tx.go
Expand Up @@ -92,11 +92,12 @@ func txSpendFunc(cmd *cobra.Command, args []string) (err error) {
// txVerifyCmd implements the tx verify subcommand.
// It verfies the signature of a signed transaction
var txVerifyCmd = &cobra.Command{
Use: "verify SENDER_ADDRESS SIGNED_TRANSACTION",
Short: "Verify the signature of a signed base64 transaction",
Long: ``,
Args: cobra.ExactArgs(2),
RunE: txVerifyFunc,
Use: "verify SENDER_ADDRESS SIGNED_TRANSACTION",
Short: "Verify the signature of a signed base64 transaction",
Long: ``,
Args: cobra.ExactArgs(2),
RunE: txVerifyFunc,
SilenceUsage: true,
}

func txVerifyFunc(cmd *cobra.Command, args []string) (err error) {
Expand All @@ -115,8 +116,14 @@ func txVerifyFunc(cmd *cobra.Command, args []string) (err error) {
err := fmt.Errorf("error while verifying signature: %s", err)
return err
}
fmt.Printf("The signature is %t\n", valid)
return nil
if valid {
fmt.Printf("The signature is valid (network-id: %s)\n", aeternity.Config.Node.NetworkID)
} else {
message := fmt.Sprintf("The signature is invalid (network-id: %s)", aeternity.Config.Node.NetworkID)
// fmt.Println(message)
err = errors.New(message)
}
return err
}

// txDumpRawCmd implements the tx dumpraw subcommand.
Expand Down

0 comments on commit 2ccd333

Please sign in to comment.