/
cmd_wallet_cancel_request.go
63 lines (53 loc) · 1.33 KB
/
cmd_wallet_cancel_request.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package client
import (
"errors"
"github.com/keybase/cli"
"github.com/keybase/client/go/libcmdline"
"github.com/keybase/client/go/libkb"
"github.com/keybase/client/go/protocol/stellar1"
"golang.org/x/net/context"
)
type CmdWalletCancelRequest struct {
libkb.Contextified
ID string
}
func newCmdWalletCancelRequest(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
cmd := &CmdWalletCancelRequest{
Contextified: libkb.NewContextified(g),
}
return cli.Command{
Name: "cancel-request",
Usage: "Cancel payment request",
ArgumentHelp: "<request id>",
Action: func(c *cli.Context) {
cl.ChooseCommand(cmd, "cancel-request", c)
},
}
}
func (c *CmdWalletCancelRequest) ParseArgv(ctx *cli.Context) error {
if len(ctx.Args()) != 1 {
return errors.New("cancel-request needs request id as the argument")
}
c.ID = ctx.Args()[0]
return nil
}
func (c *CmdWalletCancelRequest) Run() error {
cli, err := GetWalletClient(c.G())
if err != nil {
return err
}
requestID, err := stellar1.KeybaseRequestIDFromString(c.ID)
if err != nil {
return err
}
return cli.CancelRequestLocal(context.Background(), stellar1.CancelRequestLocalArg{
ReqID: requestID,
})
}
func (c *CmdWalletCancelRequest) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
API: true,
KbKeyring: true,
}
}