From c2f08f701be717bda794ff3cae1a9d095df24794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 9 Sep 2019 15:59:41 +0200 Subject: [PATCH] paych: --export flag for paych voucher list --- cli/paych.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/cli/paych.go b/cli/paych.go index 8cbf66274..9c6435034 100644 --- a/cli/paych.go +++ b/cli/paych.go @@ -202,7 +202,8 @@ var paychVoucherAddCmd = &cli.Command{ ctx := ReqContext(cctx) - if err := api.PaychVoucherAdd(ctx, ch, sv); err != nil { + // TODO: allow passing proof bytes + if err := api.PaychVoucherAdd(ctx, ch, sv, nil); err != nil { return err } @@ -213,6 +214,12 @@ var paychVoucherAddCmd = &cli.Command{ var paychVoucherListCmd = &cli.Command{ Name: "list", Usage: "List stored vouchers for a given payment channel", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "export", + Usage: "Print export strings", + }, + }, Action: func(cctx *cli.Context) error { if cctx.Args().Len() != 1 { return fmt.Errorf("must pass payment channel address") @@ -236,7 +243,16 @@ var paychVoucherListCmd = &cli.Command{ } for _, v := range vouchers { - fmt.Printf("Lane %d, Nonce %d: %s\n", v.Lane, v.Nonce, v.Amount.String()) + if cctx.Bool("export") { + enc, err := v.EncodedString() + if err != nil { + return err + } + + fmt.Printf("Lane %d, Nonce %d: %s; %s\n", v.Lane, v.Nonce, v.Amount.String(), enc) + } else { + fmt.Printf("Lane %d, Nonce %d: %s\n", v.Lane, v.Nonce, v.Amount.String()) + } } return nil