mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-31 18:21:42 +02:00
cmd/commands: export StripPrefix
This commit is contained in:
parent
4fd1abfe52
commit
2d6ba8c056
@ -42,7 +42,7 @@ func parseTime(s string, base time.Time) (uint64, error) {
|
|||||||
|
|
||||||
var lightningPrefix = "lightning:"
|
var lightningPrefix = "lightning:"
|
||||||
|
|
||||||
// stripPrefix removes accidentally copied 'lightning:' prefix.
|
// StripPrefix removes accidentally copied 'lightning:' prefix.
|
||||||
func stripPrefix(s string) string {
|
func StripPrefix(s string) string {
|
||||||
return strings.TrimSpace(strings.TrimPrefix(s, lightningPrefix))
|
return strings.TrimSpace(strings.TrimPrefix(s, lightningPrefix))
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ func TestStripPrefix(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
for _, test := range stripPrefixTests {
|
for _, test := range stripPrefixTests {
|
||||||
actual := stripPrefix(test.in)
|
actual := StripPrefix(test.in)
|
||||||
require.Equal(t, test.expected, actual)
|
require.Equal(t, test.expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ func decodePayReq(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.DecodePayReq(ctxc, &lnrpc.PayReqString{
|
resp, err := client.DecodePayReq(ctxc, &lnrpc.PayReqString{
|
||||||
PayReq: stripPrefix(payreq),
|
PayReq: StripPrefix(payreq),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -341,7 +341,7 @@ func SendPayment(ctx *cli.Context) error {
|
|||||||
// details of the payment are encoded within the request.
|
// details of the payment are encoded within the request.
|
||||||
if ctx.IsSet("pay_req") {
|
if ctx.IsSet("pay_req") {
|
||||||
req := &routerrpc.SendPaymentRequest{
|
req := &routerrpc.SendPaymentRequest{
|
||||||
PaymentRequest: stripPrefix(ctx.String("pay_req")),
|
PaymentRequest: StripPrefix(ctx.String("pay_req")),
|
||||||
Amt: ctx.Int64("amt"),
|
Amt: ctx.Int64("amt"),
|
||||||
DestCustomRecords: make(map[uint64][]byte),
|
DestCustomRecords: make(map[uint64][]byte),
|
||||||
Amp: ctx.Bool(ampFlag.Name),
|
Amp: ctx.Bool(ampFlag.Name),
|
||||||
@ -920,7 +920,7 @@ func payInvoice(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
req := &routerrpc.SendPaymentRequest{
|
req := &routerrpc.SendPaymentRequest{
|
||||||
PaymentRequest: stripPrefix(payReq),
|
PaymentRequest: StripPrefix(payReq),
|
||||||
Amt: ctx.Int64("amt"),
|
Amt: ctx.Int64("amt"),
|
||||||
DestCustomRecords: make(map[uint64][]byte),
|
DestCustomRecords: make(map[uint64][]byte),
|
||||||
Amp: ctx.Bool(ampFlag.Name),
|
Amp: ctx.Bool(ampFlag.Name),
|
||||||
@ -1922,7 +1922,7 @@ func estimateRouteFee(ctx *cli.Context) error {
|
|||||||
req.AmtSat = amtSat
|
req.AmtSat = amtSat
|
||||||
|
|
||||||
case ctx.IsSet("pay_req"):
|
case ctx.IsSet("pay_req"):
|
||||||
req.PaymentRequest = stripPrefix(ctx.String("pay_req"))
|
req.PaymentRequest = StripPrefix(ctx.String("pay_req"))
|
||||||
if ctx.IsSet("timeout") {
|
if ctx.IsSet("timeout") {
|
||||||
req.Timeout = uint32(ctx.Duration("timeout").Seconds())
|
req.Timeout = uint32(ctx.Duration("timeout").Seconds())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user