Skip to content

Commit 682379e

Browse files
committed
cmd: ln addinvoice supports msat amount
1 parent 131eda1 commit 682379e

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

cmd/litcli/ln.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,14 @@ 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",
665+
},
666+
cli.Uint64Flag{
667+
Name: "msat_amount",
668+
Usage: "the amount of msats to receive, mutually " +
669+
"exclusive to asset_amount",
664670
},
665671
cli.StringFlag{
666672
Name: "rfq_peer_pubkey",
@@ -679,12 +685,23 @@ func addInvoice(cli *cli.Context) error {
679685

680686
var (
681687
assetAmount = cli.Uint64("asset_amount")
688+
msatAmount = cli.Int64("amt_msat")
689+
satAmount = cli.Int64("amt")
682690
preimage []byte
683691
descHash []byte
684692
err error
685693
)
686-
if assetAmount == 0 {
687-
return fmt.Errorf("asset_amount argument missing")
694+
if assetAmount == 0 && msatAmount == 0 && satAmount == 0 {
695+
return fmt.Errorf("must set asset amount or sat/msat amount")
696+
}
697+
698+
if assetAmount != 0 && (msatAmount != 0 || satAmount != 0) {
699+
return fmt.Errorf("must only set one of asset amount or " +
700+
"sat/msat amount")
701+
}
702+
703+
if msatAmount != 0 && satAmount != 0 {
704+
return fmt.Errorf("must only set one of amt or amt_msat")
688705
}
689706

690707
if cli.IsSet("preimage") {
@@ -731,6 +748,8 @@ func addInvoice(cli *cli.Context) error {
731748
Memo: cli.String("memo"),
732749
RPreimage: preimage,
733750
DescriptionHash: descHash,
751+
Value: satAmount,
752+
ValueMsat: msatAmount,
734753
FallbackAddr: cli.String("fallback_addr"),
735754
Expiry: expirySeconds,
736755
Private: cli.Bool("private"),

0 commit comments

Comments
 (0)