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 }