From cb669eb1a72658ca7dad7bc49a26f4b786cacdd5 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Wed, 11 Sep 2019 14:35:25 -0400 Subject: [PATCH] add claim decode command --- cmd/decode.go | 36 ++++++++++++++++++++++++++++++++++++ go.mod | 1 + go.sum | 2 ++ 3 files changed, 39 insertions(+) create mode 100644 cmd/decode.go diff --git a/cmd/decode.go b/cmd/decode.go new file mode 100644 index 0000000..730fdb3 --- /dev/null +++ b/cmd/decode.go @@ -0,0 +1,36 @@ +package cmd + +import ( + "github.com/lbryio/lbryschema.go/claim" + + "github.com/davecgh/go-spew/spew" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +func init() { + var cmd = &cobra.Command{ + Use: "decode VALUE", + Short: "Decode a claim value", + Args: cobra.ExactArgs(1), + Run: decodeCmd, + } + rootCmd.AddCommand(cmd) +} + +func decodeCmd(cmd *cobra.Command, args []string) { + c, err := claim.DecodeClaimHex(args[0], "") + if err != nil { + log.Fatal(err) + } + + if stream := c.Claim.GetStream(); stream != nil { + spew.Dump(stream) + } else if channel := c.Claim.GetChannel(); channel != nil { + spew.Dump(channel) + } else if repost := c.Claim.GetRepost(); channel != nil { + spew.Dump(repost) + } else { + spew.Dump(c) + } +} diff --git a/go.mod b/go.mod index cbf5aec..03d5a6d 100644 --- a/go.mod +++ b/go.mod @@ -32,6 +32,7 @@ require ( github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/kr/pty v1.1.8 // indirect github.com/lbryio/lbry.go v0.0.0-20190910204236-fd916d9eae76 + github.com/lbryio/lbryschema.go v0.0.0-20190602173230-6d2f69a36f46 github.com/lbryio/types v0.0.0-20190715201353-fe180635eafe github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018 // indirect github.com/mitchellh/mapstructure v1.1.2 // indirect diff --git a/go.sum b/go.sum index bd462fc..24ee525 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,7 @@ github.com/aws/aws-sdk-go v1.16.11/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpi github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= +github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3 h1:A/EVblehb75cUgXA5njHPn0kLAsykn6mJGz7rnmW5W0= github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803 h1:j3AgPKKZtZStM2nyhrDSLSYgT7YHrZKdSkq1OYeLjvM= @@ -163,6 +164,7 @@ github.com/lbryio/lbry.go v0.0.0-20190828131228-f3a1fbdd5303 h1:CyDDxUMREhAxPlgP github.com/lbryio/lbry.go v0.0.0-20190828131228-f3a1fbdd5303/go.mod h1:qR+Ui0hYhemIU4fXqM3d1P9eiaRFlof777VJgV7KJ8w= github.com/lbryio/lbry.go v0.0.0-20190910204236-fd916d9eae76 h1:qH7uGPAFDnvNFC2lkS2AWwcmIyKInvW53AjL3Rx+JIQ= github.com/lbryio/lbry.go v0.0.0-20190910204236-fd916d9eae76/go.mod h1:qR+Ui0hYhemIU4fXqM3d1P9eiaRFlof777VJgV7KJ8w= +github.com/lbryio/lbryschema.go v0.0.0-20190602173230-6d2f69a36f46 h1:LemfR+rMxhf7nnOrzy2HqS7Me7SZ5gEwOcNFzKC8ySQ= github.com/lbryio/lbryschema.go v0.0.0-20190602173230-6d2f69a36f46/go.mod h1:dAzPCBj3CKKWBGYBZxK6tKBP5SCgY2tqd9SnQd/OyKo= github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04/go.mod h1:fbG/dzobG8r95KzMwckXiLMHfFjZaBRQqC9hPs2XAQ4= github.com/lbryio/types v0.0.0-20190422033210-321fb2abda9c h1:m3O7561xBQ00lfUVayW4c6SnpVbUDQtPUwGcGYSUYQA=