Skip to content

Commit 153a55b

Browse files
committed
cmd/litcli: add allow_overpay flag to payment cmds
1 parent a6f49b5 commit 153a55b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

cmd/litcli/ln.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ var (
182182
"set if there are multiple channels with the same " +
183183
"asset ID present",
184184
}
185+
186+
allowOverpayFlag = cli.BoolFlag{
187+
Name: "allow_overpay",
188+
Usage: "allow sending asset payments that are uneconomical " +
189+
"because the required non-dust amount for an asset " +
190+
"carrier HTLC plus one asset unit is higher than the " +
191+
"total invoice/payment amount that arrives at the " +
192+
"destination; meaning that the total amount sent " +
193+
"exceeds the total amount received plus routing fees",
194+
}
185195
)
186196

187197
// resultStreamWrapper is a wrapper around the SendPaymentClient stream that
@@ -279,7 +289,7 @@ var sendPaymentCommand = cli.Command{
279289
"--asset_amount=Y [--rfq_peer_pubkey=Z]",
280290
Flags: append(
281291
commands.SendPaymentCommand.Flags, assetIDFlag, assetAmountFlag,
282-
rfqPeerPubKeyFlag,
292+
rfqPeerPubKeyFlag, allowOverpayFlag,
283293
),
284294
Action: sendPayment,
285295
}
@@ -380,6 +390,7 @@ func sendPayment(ctx *cli.Context) error {
380390
rHash = hash[:]
381391

382392
req.PaymentHash = rHash
393+
allowOverpay := ctx.Bool(allowOverpayFlag.Name)
383394

384395
return commands.SendPaymentRequest(
385396
ctx, req, lndConn, tapdConn, func(ctx context.Context,
@@ -397,6 +408,7 @@ func sendPayment(ctx *cli.Context) error {
397408
AssetAmount: assetAmountToSend,
398409
PeerPubkey: rfqPeerKey,
399410
PaymentRequest: req,
411+
AllowOverpay: allowOverpay,
400412
},
401413
)
402414
if err != nil {
@@ -428,6 +440,7 @@ var payInvoiceCommand = cli.Command{
428440
},
429441
assetIDFlag,
430442
rfqPeerPubKeyFlag,
443+
allowOverpayFlag,
431444
),
432445
Action: payInvoice,
433446
}
@@ -472,15 +485,13 @@ func payInvoice(ctx *cli.Context) error {
472485
return fmt.Errorf("unable to decode assetID: %v", err)
473486
}
474487

475-
var assetID asset.ID
476-
copy(assetID[:], assetIDBytes)
477-
478488
rfqPeerKey, err := hex.DecodeString(ctx.String(rfqPeerPubKeyFlag.Name))
479489
if err != nil {
480490
return fmt.Errorf("unable to decode RFQ peer public key: "+
481491
"%w", err)
482492
}
483493

494+
allowOverpay := ctx.Bool(allowOverpayFlag.Name)
484495
req := &routerrpc.SendPaymentRequest{
485496
PaymentRequest: commands.StripPrefix(payReq),
486497
}
@@ -500,6 +511,7 @@ func payInvoice(ctx *cli.Context) error {
500511
AssetId: assetIDBytes,
501512
PeerPubkey: rfqPeerKey,
502513
PaymentRequest: req,
514+
AllowOverpay: allowOverpay,
503515
},
504516
)
505517
if err != nil {

0 commit comments

Comments
 (0)