routerrpc: fix sendpayment_v2 negative fee limit

This commit is contained in:
Slyghtning 2024-11-13 20:16:12 +01:00
parent 0876173c45
commit 8f8942cda9
No known key found for this signature in database
GPG Key ID: F82D456EA023C9BF

View File

@ -23,6 +23,9 @@ var (
ErrSatMsatMutualExclusive = errors.New(
"sat and msat arguments are mutually exclusive",
)
// ErrNegativeAmt is returned when a negative amount is specified.
ErrNegativeAmt = errors.New("amount cannot be negative")
)
// CalculateFeeLimit returns the fee limit in millisatoshis. If a percentage
@ -56,6 +59,10 @@ func UnmarshallAmt(amtSat, amtMsat int64) (lnwire.MilliSatoshi, error) {
return 0, ErrSatMsatMutualExclusive
}
if amtSat < 0 || amtMsat < 0 {
return 0, ErrNegativeAmt
}
if amtSat != 0 {
return lnwire.NewMSatFromSatoshis(btcutil.Amount(amtSat)), nil
}