cmd: ln addinvoice supports sat/msat amount

This commit is contained in:
George Tsagkarelis 2025-05-16 14:18:37 +02:00
parent 0015ca29af
commit 17ab5e21dd
No known key found for this signature in database
GPG key ID: E08DEA9B12B66AF6

View file

@ -679,12 +679,23 @@ func addInvoice(cli *cli.Context) error {
var (
assetAmount = cli.Uint64("asset_amount")
msatAmount = cli.Int64("amt_msat")
satAmount = cli.Int64("amt")
preimage []byte
descHash []byte
err error
)
if assetAmount == 0 {
return fmt.Errorf("asset_amount argument missing")
if assetAmount == 0 && msatAmount == 0 && satAmount == 0 {
return fmt.Errorf("must set asset amount or sat/msat amount")
}
if assetAmount != 0 && (msatAmount != 0 || satAmount != 0) {
return fmt.Errorf("must only set one of asset amount or " +
"sat/msat amount")
}
if msatAmount != 0 && satAmount != 0 {
return fmt.Errorf("must only set one of amt or amt_msat")
}
if cli.IsSet("preimage") {
@ -731,6 +742,8 @@ func addInvoice(cli *cli.Context) error {
Memo: cli.String("memo"),
RPreimage: preimage,
DescriptionHash: descHash,
Value: satAmount,
ValueMsat: msatAmount,
FallbackAddr: cli.String("fallback_addr"),
Expiry: expirySeconds,
Private: cli.Bool("private"),