From 266aba8a6c45c715606eab7922e861ee5e41fe8e Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 13 Sep 2024 15:47:33 +0200 Subject: [PATCH] lnwallet: allow read-only access to HtlcView's HTLCs Due to a recent refactor, the HTLCs are no longer an exported type. Custom channels need access to those updates, so we provide them in a read-only manner. --- lnwallet/channel.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 32492171f..a208cda93 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -2545,6 +2545,18 @@ type HtlcView struct { FeePerKw chainfee.SatPerKWeight } +// AuxOurUpdates returns the outgoing HTLCs as a read-only copy of +// AuxHtlcDescriptors. +func (v *HtlcView) AuxOurUpdates() []AuxHtlcDescriptor { + return fn.Map(newAuxHtlcDescriptor, v.OurUpdates) +} + +// AuxTheirUpdates returns the incoming HTLCs as a read-only copy of +// AuxHtlcDescriptors. +func (v *HtlcView) AuxTheirUpdates() []AuxHtlcDescriptor { + return fn.Map(newAuxHtlcDescriptor, v.TheirUpdates) +} + // fetchHTLCView returns all the candidate HTLC updates which should be // considered for inclusion within a commitment based on the passed HTLC log // indexes.