From e776a06cfb1eb933f7001ecdab21a69137d4665c Mon Sep 17 00:00:00 2001 From: Stefan Menzel Date: Thu, 26 Jul 2018 05:11:46 +0200 Subject: [PATCH] rpc: disallow a negative invoice amount in AddInvoice --- rpcserver.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rpcserver.go b/rpcserver.go index 0296639a..9261debe 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2445,6 +2445,12 @@ func (r *rpcServer) AddInvoice(ctx context.Context, len(invoice.DescriptionHash), channeldb.MaxPaymentRequestSize) } + // The value of the invoice must not be negative. + if invoice.Value < 0 { + return nil, fmt.Errorf("payments of negative value "+ + "are not allowed, value is %v", invoice.Value) + } + amt := btcutil.Amount(invoice.Value) amtMSat := lnwire.NewMSatFromSatoshis(amt)