lnwallet: add custom tlv blob to internal commitment struct

In this commit, we also add the custom TLV blob to the internal commitment struct that we use within the in-memory commitment linked list.

This'll be useful to ensure that we're tracking the current blob for our in memory commitment for when we need to write it to disk.
This commit is contained in:
Olaoluwa Osuntokun 2024-04-01 20:07:15 -07:00 committed by Oliver Gugger
parent 5733bbb55c
commit 12acbac16a
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -32,6 +32,7 @@ import (
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/shachain"
"github.com/lightningnetwork/lnd/tlv"
)
var (
@ -546,6 +547,10 @@ type commitment struct {
// on this commitment transaction.
incomingHTLCs []PaymentDescriptor
// customBlob stores opaque bytes that may be used by custom channels
// to store extra data for a given commitment state.
customBlob fn.Option[tlv.Blob]
// [outgoing|incoming]HTLCIndex is an index that maps an output index
// on the commitment transaction to the payment descriptor that
// represents the HTLC output.
@ -726,6 +731,7 @@ func (c *commitment) toDiskCommit(ourCommit bool) *channeldb.ChannelCommitment {
CommitTx: c.txn,
CommitSig: c.sig,
Htlcs: make([]channeldb.HTLC, 0, numHtlcs),
CustomBlob: c.customBlob,
}
for _, htlc := range c.outgoingHTLCs {
@ -971,6 +977,7 @@ func (lc *LightningChannel) diskCommitToMemCommit(isLocal bool,
feePerKw: chainfee.SatPerKWeight(diskCommit.FeePerKw),
incomingHTLCs: incomingHtlcs,
outgoingHTLCs: outgoingHtlcs,
customBlob: diskCommit.CustomBlob,
}
if isLocal {
commit.dustLimit = lc.channelState.LocalChanCfg.DustLimit