2017-11-08 03:41:07 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-11-20 19:44:19 +01:00
|
|
|
"os"
|
2020-09-01 19:45:55 +02:00
|
|
|
|
2021-10-06 20:00:59 +02:00
|
|
|
"github.com/lbryio/lbry.go/v3/schema/stake"
|
2017-11-08 03:41:07 +01:00
|
|
|
)
|
|
|
|
|
2017-11-20 19:44:19 +01:00
|
|
|
func main() {
|
2017-11-08 03:41:07 +01:00
|
|
|
args := os.Args[1:]
|
|
|
|
if len(args) == 1 {
|
2018-02-15 20:51:51 +01:00
|
|
|
claimBytes := []byte(args[0])
|
2020-10-28 06:36:49 +01:00
|
|
|
decoded, err := stake.DecodeClaimBytes(claimBytes, "lbrycrd_main")
|
2017-11-08 03:41:07 +01:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Decoding error:", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
text, err := decoded.RenderJSON()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Decoding error:", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
fmt.Println(text)
|
|
|
|
return
|
|
|
|
} else if (len(args) == 2) && (args[1] == "--decode_hex") {
|
2018-02-15 20:51:51 +01:00
|
|
|
claimHex := args[0]
|
2020-10-28 06:36:49 +01:00
|
|
|
decoded, err := stake.DecodeClaimHex(claimHex, "lbrycrd_main")
|
2017-11-08 03:41:07 +01:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Decoding error:", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
text, err := decoded.RenderJSON()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Decoding error:", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
fmt.Println(text)
|
|
|
|
return
|
|
|
|
} else {
|
|
|
|
fmt.Println("encountered an error\nusage: \n\tlbryschema-cli <value to decode> [--decode_hex]")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|