Skip to content

Commit

Permalink
add hex cleaning for puzzle hash argument values
Browse files Browse the repository at this point in the history
  • Loading branch information
leonid-ed committed Mar 10, 2024
1 parent cec37eb commit acc6c33
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/cmd/coinset/get_address_by_puzzle_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var getAddressByPuzzleHashCmd = &cobra.Command{
jsonData := map[string]interface{}{}
jsonData["puzzle_hash"] = formatHex(args[0])

hexBytes, err := hex.DecodeString(args[0])
hexBytes, err := hex.DecodeString(cleanHex(args[0]))
if err != nil {
fmt.Println(err)
return
Expand Down
7 changes: 7 additions & 0 deletions internal/cmd/coinset/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ func formatHex(str string) string {
return "0x" + str
}

func cleanHex(str string) string {
if str[:2] == "0x" {
return str[2:]
}
return str
}

func apiRoot() string {
if api != "" {
return api
Expand Down

0 comments on commit acc6c33

Please sign in to comment.