@@ -288,7 +288,7 @@ type InitFundingMsg struct {
288288 // PendingChanID is not all zeroes (the default value), then this will
289289 // be the pending channel ID used for the funding flow within the wire
290290 // protocol.
291- PendingChanID [ 32 ] byte
291+ PendingChanID PendingChanID
292292
293293 // ChannelType allows the caller to use an explicit channel type for the
294294 // funding negotiation. This type will only be observed if BOTH sides
@@ -318,7 +318,7 @@ type fundingMsg struct {
318318// pendingChannels is a map instantiated per-peer which tracks all active
319319// pending single funded channels indexed by their pending channel identifier,
320320// which is a set of 32-bytes generated via a CSPRNG.
321- type pendingChannels map [[ 32 ] byte ]* reservationWithCtx
321+ type pendingChannels map [PendingChanID ]* reservationWithCtx
322322
323323// serializedPubKey is used within the FundingManager's activeReservations list
324324// to identify the nodes with which the FundingManager is actively working to
@@ -586,7 +586,7 @@ type Manager struct {
586586 // required as mid funding flow, we switch to referencing the channel
587587 // by its full channel ID once the commitment transactions have been
588588 // signed by both parties.
589- signedReservations map [lnwire.ChannelID ][ 32 ] byte
589+ signedReservations map [lnwire.ChannelID ]PendingChanID
590590
591591 // resMtx guards both of the maps above to ensure that all access is
592592 // goroutine safe.
@@ -793,9 +793,13 @@ func (f *Manager) rebroadcastFundingTx(c *channeldb.OpenChannel) {
793793 }
794794}
795795
796+ // PendingChanID is a type that represents a pending channel ID. This might be
797+ // selected by the caller, but if not, will be automatically selected.
798+ type PendingChanID = [32 ]byte
799+
796800// nextPendingChanID returns the next free pending channel ID to be used to
797801// identify a particular future channel funding workflow.
798- func (f * Manager ) nextPendingChanID () [ 32 ] byte {
802+ func (f * Manager ) nextPendingChanID () PendingChanID {
799803 // Obtain a fresh nonce. We do this by encoding the current nonce
800804 // counter, then incrementing it by one.
801805 f .nonceMtx .Lock ()
@@ -807,7 +811,7 @@ func (f *Manager) nextPendingChanID() [32]byte {
807811 // We'll generate the next pending channelID by "encrypting" 32-bytes
808812 // of zeroes which'll extract 32 random bytes from our stream cipher.
809813 var (
810- nextChanID [ 32 ] byte
814+ nextChanID PendingChanID
811815 zeroes [32 ]byte
812816 )
813817 salsa20 .XORKeyStream (nextChanID [:], zeroes [:], nonce [:], & f .chanIDKey )
@@ -1040,7 +1044,8 @@ func (f *Manager) reservationCoordinator() {
10401044//
10411045// NOTE: This MUST be run as a goroutine.
10421046func (f * Manager ) advanceFundingState (channel * channeldb.OpenChannel ,
1043- pendingChanID [32 ]byte , updateChan chan <- * lnrpc.OpenStatusUpdate ) {
1047+ pendingChanID PendingChanID ,
1048+ updateChan chan <- * lnrpc.OpenStatusUpdate ) {
10441049
10451050 defer f .wg .Done ()
10461051
@@ -1110,7 +1115,7 @@ func (f *Manager) advanceFundingState(channel *channeldb.OpenChannel,
11101115// updateChan can be set non-nil to get OpenStatusUpdates.
11111116func (f * Manager ) stateStep (channel * channeldb.OpenChannel ,
11121117 lnChannel * lnwallet.LightningChannel ,
1113- shortChanID * lnwire.ShortChannelID , pendingChanID [ 32 ] byte ,
1118+ shortChanID * lnwire.ShortChannelID , pendingChanID PendingChanID ,
11141119 channelState channelOpeningState ,
11151120 updateChan chan <- * lnrpc.OpenStatusUpdate ) error {
11161121
@@ -1234,7 +1239,7 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel,
12341239// advancePendingChannelState waits for a pending channel's funding tx to
12351240// confirm, and marks it open in the database when that happens.
12361241func (f * Manager ) advancePendingChannelState (
1237- channel * channeldb.OpenChannel , pendingChanID [ 32 ] byte ) error {
1242+ channel * channeldb.OpenChannel , pendingChanID PendingChanID ) error {
12381243
12391244 if channel .IsZeroConf () {
12401245 // Persist the alias to the alias database.
@@ -2735,7 +2740,7 @@ type confirmedChannel struct {
27352740// channel as closed. The error is only returned for the responder of the
27362741// channel flow.
27372742func (f * Manager ) fundingTimeout (c * channeldb.OpenChannel ,
2738- pendingID [ 32 ] byte ) error {
2743+ pendingID PendingChanID ) error {
27392744
27402745 // We'll get a timeout if the number of blocks mined since the channel
27412746 // was initiated reaches MaxWaitNumBlocksFundingConf and we are not the
@@ -3598,7 +3603,7 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
35983603// a zero-conf channel. This will wait for the real confirmation, add the
35993604// confirmed SCID to the router graph, and then announce after six confs.
36003605func (f * Manager ) waitForZeroConfChannel (c * channeldb.OpenChannel ,
3601- pendingID [ 32 ] byte ) error {
3606+ pendingID PendingChanID ) error {
36023607
36033608 // First we'll check whether the channel is confirmed on-chain. If it
36043609 // is already confirmed, the chainntnfs subsystem will return with the
@@ -3966,7 +3971,7 @@ func (f *Manager) handleChannelReady(peer lnpeer.Peer, //nolint:funlen
39663971// channel is now active, thus we change its state to `addedToRouterGraph` to
39673972// let the channel start handling routing.
39683973func (f * Manager ) handleChannelReadyReceived (channel * channeldb.OpenChannel ,
3969- scid * lnwire.ShortChannelID , pendingChanID [ 32 ] byte ,
3974+ scid * lnwire.ShortChannelID , pendingChanID PendingChanID ,
39703975 updateChan chan <- * lnrpc.OpenStatusUpdate ) error {
39713976
39723977 chanID := lnwire .NewChanIDFromOutPoint (channel .FundingOutpoint )
@@ -4490,7 +4495,7 @@ func (f *Manager) handleInitFundingMsg(msg *InitFundingMsg) {
44904495 // If the caller specified their own channel ID, then we'll use that.
44914496 // Otherwise we'll generate a fresh one as normal. This will be used
44924497 // to track this reservation throughout its lifetime.
4493- var chanID [ 32 ] byte
4498+ var chanID PendingChanID
44944499 if msg .PendingChanID == zeroID {
44954500 chanID = f .nextPendingChanID ()
44964501 } else {
@@ -4895,7 +4900,8 @@ func (f *Manager) pruneZombieReservations() {
48954900// cancelReservationCtx does all needed work in order to securely cancel the
48964901// reservation.
48974902func (f * Manager ) cancelReservationCtx (peerKey * btcec.PublicKey ,
4898- pendingChanID [32 ]byte , byRemote bool ) (* reservationWithCtx , error ) {
4903+ pendingChanID PendingChanID ,
4904+ byRemote bool ) (* reservationWithCtx , error ) {
48994905
49004906 log .Infof ("Cancelling funding reservation for node_key=%x, " +
49014907 "chan_id=%x" , peerKey .SerializeCompressed (), pendingChanID [:])
@@ -4943,7 +4949,7 @@ func (f *Manager) cancelReservationCtx(peerKey *btcec.PublicKey,
49434949// deleteReservationCtx deletes the reservation uniquely identified by the
49444950// target public key of the peer, and the specified pending channel ID.
49454951func (f * Manager ) deleteReservationCtx (peerKey * btcec.PublicKey ,
4946- pendingChanID [ 32 ] byte ) {
4952+ pendingChanID PendingChanID ) {
49474953
49484954 peerIDKey := newSerializedKey (peerKey )
49494955 f .resMtx .Lock ()
@@ -4966,7 +4972,7 @@ func (f *Manager) deleteReservationCtx(peerKey *btcec.PublicKey,
49664972// getReservationCtx returns the reservation context for a particular pending
49674973// channel ID for a target peer.
49684974func (f * Manager ) getReservationCtx (peerKey * btcec.PublicKey ,
4969- pendingChanID [ 32 ] byte ) (* reservationWithCtx , error ) {
4975+ pendingChanID PendingChanID ) (* reservationWithCtx , error ) {
49704976
49714977 peerIDKey := newSerializedKey (peerKey )
49724978 f .resMtx .RLock ()
@@ -4986,7 +4992,7 @@ func (f *Manager) getReservationCtx(peerKey *btcec.PublicKey,
49864992// of being funded. After the funding transaction has been confirmed, the
49874993// channel will receive a new, permanent channel ID, and will no longer be
49884994// considered pending.
4989- func (f * Manager ) IsPendingChannel (pendingChanID [ 32 ] byte ,
4995+ func (f * Manager ) IsPendingChannel (pendingChanID PendingChanID ,
49904996 peer lnpeer.Peer ) bool {
49914997
49924998 peerIDKey := newSerializedKey (peer .IdentityKey ())
0 commit comments