From 8f8942cda98acb43678c0af4d0381505c9b28d11 Mon Sep 17 00:00:00 2001 From: Slyghtning Date: Wed, 13 Nov 2024 20:16:12 +0100 Subject: [PATCH] routerrpc: fix sendpayment_v2 negative fee limit --- lnrpc/marshall_utils.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lnrpc/marshall_utils.go b/lnrpc/marshall_utils.go index 0dcbe46fa..230fea35b 100644 --- a/lnrpc/marshall_utils.go +++ b/lnrpc/marshall_utils.go @@ -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 }