From be4134553f9ae60dfbd3703c87d80e1b3bcd232e Mon Sep 17 00:00:00 2001 From: George Tsagkarelis Date: Mon, 1 Sep 2025 16:38:49 +0200 Subject: [PATCH] lnwallet: include peer pub key in aux chan state In order to help external components to query the custom records of a channel we need to expose the remote peer pub key. We could look-up custom records based on the funding outpoint, but that relation is established when receiving the ChannelReady message. The external components may query the AuxChanState before that message is received, so let's make sure the peer pub key is also available. --- lnwallet/aux_leaf_store.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lnwallet/aux_leaf_store.go b/lnwallet/aux_leaf_store.go index aa2cc3b3e..0a8505037 100644 --- a/lnwallet/aux_leaf_store.go +++ b/lnwallet/aux_leaf_store.go @@ -9,6 +9,7 @@ import ( "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwire" + "github.com/lightningnetwork/lnd/routing/route" "github.com/lightningnetwork/lnd/tlv" ) @@ -97,6 +98,10 @@ type AuxChanState struct { // funding output. TapscriptRoot fn.Option[chainhash.Hash] + // PeerPubKey is the peer pub key of the peer we've established this + // channel with. + PeerPubKey route.Vertex + // CustomBlob is an optional blob that can be used to store information // specific to a custom channel type. This information is only created // at channel funding time, and after wards is to be considered @@ -106,6 +111,8 @@ type AuxChanState struct { // NewAuxChanState creates a new AuxChanState from the given channel state. func NewAuxChanState(chanState *channeldb.OpenChannel) AuxChanState { + peerPub := chanState.IdentityPub.SerializeCompressed() + return AuxChanState{ ChanType: chanState.ChanType, FundingOutpoint: chanState.FundingOutpoint, @@ -116,6 +123,7 @@ func NewAuxChanState(chanState *channeldb.OpenChannel) AuxChanState { RemoteChanCfg: chanState.RemoteChanCfg, ThawHeight: chanState.ThawHeight, TapscriptRoot: chanState.TapscriptRoot, + PeerPubKey: route.Vertex(peerPub), CustomBlob: chanState.CustomBlob, } }