From acc6c333279abfc0463c900754f19af165bddab1 Mon Sep 17 00:00:00 2001 From: Leonid Edrenkin Date: Sun, 10 Mar 2024 22:20:45 +0100 Subject: [PATCH] add hex cleaning for puzzle hash argument values --- internal/cmd/coinset/get_address_by_puzzle_hash.go | 2 +- internal/cmd/coinset/util.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/cmd/coinset/get_address_by_puzzle_hash.go b/internal/cmd/coinset/get_address_by_puzzle_hash.go index b8f15d4..a39369d 100644 --- a/internal/cmd/coinset/get_address_by_puzzle_hash.go +++ b/internal/cmd/coinset/get_address_by_puzzle_hash.go @@ -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 diff --git a/internal/cmd/coinset/util.go b/internal/cmd/coinset/util.go index 86bddcb..8c788ec 100644 --- a/internal/cmd/coinset/util.go +++ b/internal/cmd/coinset/util.go @@ -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