Skip to content

Commit 8f8942c

Browse files
committed
routerrpc: fix sendpayment_v2 negative fee limit
1 parent 0876173 commit 8f8942c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lnrpc/marshall_utils.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ var (
2323
ErrSatMsatMutualExclusive = errors.New(
2424
"sat and msat arguments are mutually exclusive",
2525
)
26+
27+
// ErrNegativeAmt is returned when a negative amount is specified.
28+
ErrNegativeAmt = errors.New("amount cannot be negative")
2629
)
2730

2831
// CalculateFeeLimit returns the fee limit in millisatoshis. If a percentage
@@ -56,6 +59,10 @@ func UnmarshallAmt(amtSat, amtMsat int64) (lnwire.MilliSatoshi, error) {
5659
return 0, ErrSatMsatMutualExclusive
5760
}
5861

62+
if amtSat < 0 || amtMsat < 0 {
63+
return 0, ErrNegativeAmt
64+
}
65+
5966
if amtSat != 0 {
6067
return lnwire.NewMSatFromSatoshis(btcutil.Amount(amtSat)), nil
6168
}

0 commit comments

Comments
 (0)