mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-31 17:51:33 +02:00
channeldb: store optional invoice fields as variable length byte arrays
This commit modifies the on-disk storage of invoices to stop the optional fields (memo+receipt) on-disk as variable length byte arrays. This change saves space as the optional fields now only take up as much space as is strictly needed, rather than always being padded out to max size (1KB).
This commit is contained in:
@@ -613,12 +613,12 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
|
||||
|
||||
i := &channeldb.Invoice{
|
||||
CreationDate: time.Now(),
|
||||
Memo: []byte(invoice.Memo),
|
||||
Receipt: invoice.Receipt,
|
||||
Terms: channeldb.ContractTerm{
|
||||
Value: btcutil.Amount(invoice.Value),
|
||||
},
|
||||
}
|
||||
copy(i.Memo[:], invoice.Memo)
|
||||
copy(i.Receipt[:], invoice.Receipt)
|
||||
copy(i.Terms.PaymentPreimage[:], preImage)
|
||||
|
||||
if err := r.server.invoices.AddInvoice(i); err != nil {
|
||||
|
Reference in New Issue
Block a user