mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-24 06:47:44 +01:00
rpc: disallow a negative invoice amount in AddInvoice
This commit is contained in:
parent
8cd6eebadc
commit
e776a06cfb
1 changed files with 6 additions and 0 deletions
|
@ -2445,6 +2445,12 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
|
||||||
len(invoice.DescriptionHash), channeldb.MaxPaymentRequestSize)
|
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)
|
amt := btcutil.Amount(invoice.Value)
|
||||||
amtMSat := lnwire.NewMSatFromSatoshis(amt)
|
amtMSat := lnwire.NewMSatFromSatoshis(amt)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue