diff --git a/htlcswitch/interfaces.go b/htlcswitch/interfaces.go index f5b3bbe98..4e6384b97 100644 --- a/htlcswitch/interfaces.go +++ b/htlcswitch/interfaces.go @@ -13,6 +13,7 @@ import ( "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/record" + "github.com/lightningnetwork/lnd/tlv" ) // InvoiceDatabase is an interface which represents the persistent subsystem @@ -278,6 +279,16 @@ type ChannelLink interface { // have buffered messages. AttachMailBox(MailBox) + // FundingCustomBlob returns the custom funding blob of the channel that + // this link is associated with. The funding blob represents static + // information about the channel that was created at channel funding + // time. + FundingCustomBlob() fn.Option[tlv.Blob] + + // CommitmentCustomBlob returns the custom blob of the current local + // commitment of the channel that this link is associated with. + CommitmentCustomBlob() fn.Option[tlv.Blob] + // Start/Stop are used to initiate the start/stop of the channel link // functioning. Start() error diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 57d531935..a8e35afe6 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -31,6 +31,7 @@ import ( "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/queue" "github.com/lightningnetwork/lnd/ticker" + "github.com/lightningnetwork/lnd/tlv" ) func init() { @@ -4105,3 +4106,28 @@ func (l *channelLink) failf(linkErr LinkFailureError, format string, l.failed = true l.cfg.OnChannelFailure(l.ChanID(), l.ShortChanID(), linkErr) } + +// FundingCustomBlob returns the custom funding blob of the channel that this +// link is associated with. The funding blob represents static information about +// the channel that was created at channel funding time. +func (l *channelLink) FundingCustomBlob() fn.Option[tlv.Blob] { + if l.channel == nil { + return fn.None[tlv.Blob]() + } + + if l.channel.State() == nil { + return fn.None[tlv.Blob]() + } + + return l.channel.State().CustomBlob +} + +// CommitmentCustomBlob returns the custom blob of the current local commitment +// of the channel that this link is associated with. +func (l *channelLink) CommitmentCustomBlob() fn.Option[tlv.Blob] { + if l.channel == nil { + return fn.None[tlv.Blob]() + } + + return l.channel.LocalCommitmentBlob() +} diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index c328bc533..6d27a5be9 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -35,6 +35,7 @@ import ( "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/ticker" + "github.com/lightningnetwork/lnd/tlv" ) func isAlias(scid lnwire.ShortChannelID) bool { @@ -950,6 +951,14 @@ func (f *mockChannelLink) OnCommitOnce(LinkDirection, func()) { // TODO(proofofkeags): Implement } +func (f *mockChannelLink) FundingCustomBlob() fn.Option[tlv.Blob] { + return fn.None[tlv.Blob]() +} + +func (f *mockChannelLink) CommitmentCustomBlob() fn.Option[tlv.Blob] { + return fn.None[tlv.Blob]() +} + var _ ChannelLink = (*mockChannelLink)(nil) func newDB() (*channeldb.DB, func(), error) {