Skip to content

Commit a4360fb

Browse files
committed
cmd: ln addinvoice supports sat/msat amount
1 parent 131eda1 commit a4360fb

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

cmd/litcli/ln.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,9 @@ var addInvoiceCommand = cli.Command{
659659
"cannot be used at the same time as --asset_id",
660660
},
661661
cli.Uint64Flag{
662-
Name: "asset_amount",
663-
Usage: "the amount of assets to receive",
662+
Name: "asset_amount",
663+
Usage: "the amount of assets to receive, mutually " +
664+
"exclusive to msat_amount",
664665
},
665666
cli.StringFlag{
666667
Name: "rfq_peer_pubkey",
@@ -679,12 +680,23 @@ func addInvoice(cli *cli.Context) error {
679680

680681
var (
681682
assetAmount = cli.Uint64("asset_amount")
683+
msatAmount = cli.Int64("amt_msat")
684+
satAmount = cli.Int64("amt")
682685
preimage []byte
683686
descHash []byte
684687
err error
685688
)
686-
if assetAmount == 0 {
687-
return fmt.Errorf("asset_amount argument missing")
689+
if assetAmount == 0 && msatAmount == 0 && satAmount == 0 {
690+
return fmt.Errorf("must set asset amount or sat/msat amount")
691+
}
692+
693+
if assetAmount != 0 && (msatAmount != 0 || satAmount != 0) {
694+
return fmt.Errorf("must only set one of asset amount or " +
695+
"sat/msat amount")
696+
}
697+
698+
if msatAmount != 0 && satAmount != 0 {
699+
return fmt.Errorf("must only set one of amt or amt_msat")
688700
}
689701

690702
if cli.IsSet("preimage") {
@@ -731,6 +743,8 @@ func addInvoice(cli *cli.Context) error {
731743
Memo: cli.String("memo"),
732744
RPreimage: preimage,
733745
DescriptionHash: descHash,
746+
Value: satAmount,
747+
ValueMsat: msatAmount,
734748
FallbackAddr: cli.String("fallback_addr"),
735749
Expiry: expirySeconds,
736750
Private: cli.Bool("private"),

0 commit comments

Comments
 (0)