forked from aergoio/aergo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
receipt.go
43 lines (38 loc) · 867 Bytes
/
receipt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @file
* @copyright defined in aergo/LICENSE.txt
*/
package cmd
import (
"context"
"log"
"github.com/aergoio/aergo/cmd/aergocli/util"
aergorpc "github.com/aergoio/aergo/types"
"github.com/mr-tron/base58/base58"
"github.com/spf13/cobra"
)
func init() {
receiptCmd := &cobra.Command{
Use: "receipt [flags] subcommand",
Short: "Receipt command",
}
rootCmd.AddCommand(receiptCmd)
receiptCmd.AddCommand(
&cobra.Command{
Use: "get [flags] tx_hash",
Short: "Get a receipt",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
txHash, err := base58.Decode(args[0])
if err != nil {
log.Fatal(err)
}
msg, err := client.GetReceipt(context.Background(), &aergorpc.SingleBytes{Value: txHash})
if err != nil {
log.Fatal(err)
}
cmd.Println(util.JSON(msg))
},
},
)
}