File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,12 @@ package commands
33import (
44 "encoding/hex"
55 "fmt"
6+ "os"
67 "strconv"
78 "strings"
89
910 "github.com/lightningnetwork/lnd/lnrpc"
11+ qrterminal "github.com/mdp/qrterminal/v3"
1012 "github.com/urfave/cli"
1113 "google.golang.org/protobuf/proto"
1214)
@@ -124,6 +126,11 @@ var AddInvoiceCommand = cli.Command{
124126 "id (separated by commas), starting from a " +
125127 "channel which points to the self node." ,
126128 },
129+ cli.BoolFlag {
130+ Name : "qr" ,
131+ Usage : "display a QR code of the payment request " +
132+ "in the terminal" ,
133+ },
127134 },
128135 Action : actionDecorator (addInvoice ),
129136}
@@ -202,6 +209,15 @@ func addInvoice(ctx *cli.Context) error {
202209
203210 printRespJSON (resp )
204211
212+ if ctx .Bool ("qr" ) {
213+ // If the user requested it, we'll also print a QR code that
214+ // encodes the payment request for easy scanning.
215+ fmt .Println ()
216+ qrterminal .GenerateHalfBlock (
217+ resp .PaymentRequest , qrterminal .L , os .Stdout ,
218+ )
219+ }
220+
205221 return nil
206222}
207223
Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ require (
130130 github.com/mattn/go-isatty v0.0.20 // indirect
131131 github.com/mattn/go-runewidth v0.0.13 // indirect
132132 github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
133+ github.com/mdp/qrterminal/v3 v3.2.1
133134 github.com/moby/docker-image-spec v1.3.1 // indirect
134135 github.com/moby/term v0.5.0 // indirect
135136 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@@ -199,6 +200,7 @@ require (
199200 modernc.org/sqlite v1.29.10 // indirect
200201 modernc.org/strutil v1.2.0 // indirect
201202 modernc.org/token v1.1.0 // indirect
203+ rsc.io/qr v0.2.0 // indirect
202204 sigs.k8s.io/yaml v1.2.0 // indirect
203205)
204206
Original file line number Diff line number Diff line change @@ -405,6 +405,8 @@ github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4
405405github.com/mattn/go-runewidth v0.0.13 /go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w =
406406github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU =
407407github.com/matttproud/golang_protobuf_extensions v1.0.1 /go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0 =
408+ github.com/mdp/qrterminal/v3 v3.2.1 h1:6+yQjiiOsSuXT5n9/m60E54vdgFsw0zhADHhHLrFet4 =
409+ github.com/mdp/qrterminal/v3 v3.2.1 /go.mod h1:jOTmXvnBsMy5xqLniO0R++Jmjs2sTm9dFSuQ5kpz/SU =
408410github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg =
409411github.com/miekg/dns v1.1.43 /go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4 =
410412github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0 =
@@ -852,5 +854,7 @@ modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
852854modernc.org/token v1.1.0 /go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM =
853855pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk =
854856pgregory.net/rapid v1.2.0 /go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04 =
857+ rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY =
858+ rsc.io/qr v0.2.0 /go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs =
855859sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q =
856860sigs.k8s.io/yaml v1.2.0 /go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc =
You can’t perform that action at this time.
0 commit comments