mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-31 16:55:13 +02:00
channeldb: explicitly store the FinalCltvDelta within the ContractTerm struct
In this commit, we move to explicitly storing a bit more information within the invoice. Currently this information is already stored in the payment request, but by storing it at this level, callers that may not be in the state to fully decode a payment request can obtain this data. We avoid a database migration by appending this data to the end of an invoice. When decoding, we'll try to read out this extra information, and simply return what we have if it isn't found.
This commit is contained in:
@@ -3,6 +3,7 @@ package channeldb
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
prand "math/rand"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -24,6 +25,7 @@ func randInvoice(value lnwire.MilliSatoshi) (*Invoice, error) {
|
||||
Terms: ContractTerm{
|
||||
PaymentPreimage: pre,
|
||||
Value: value,
|
||||
FinalCltvDelta: uint16(prand.Int31()),
|
||||
},
|
||||
}
|
||||
i.Memo = []byte("memo")
|
||||
@@ -66,6 +68,7 @@ func TestInvoiceWorkflow(t *testing.T) {
|
||||
fakeInvoice.PaymentRequest = []byte("")
|
||||
copy(fakeInvoice.Terms.PaymentPreimage[:], rev[:])
|
||||
fakeInvoice.Terms.Value = lnwire.NewMSatFromSatoshis(10000)
|
||||
fakeInvoice.Terms.FinalCltvDelta = uint16(prand.Int31())
|
||||
|
||||
// Add the invoice to the database, this should succeed as there aren't
|
||||
// any existing invoices within the database with the same payment
|
||||
|
Reference in New Issue
Block a user