From 82b7891e2dcfb7108af0f5e56d8f33c0fd1bb5ec Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 13 Mar 2025 14:26:06 -0500 Subject: [PATCH] rpcserver: add custom channel data to pending channels The pending force close and pending waiting close channels didn't have their custom channel data populated yet. --- rpcserver.go | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 41f84ff8a..07b6bc60c 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -4028,6 +4028,13 @@ func (r *rpcServer) fetchPendingForceCloseChannels() (pendingForceClose, historical.LocalCommitment.RemoteBalance.ToSatoshis(), ) + customChanBytes, err := encodeCustomChanData(historical) + if err != nil { + return nil, 0, fmt.Errorf("unable to encode "+ + "open chan data: %w", err) + } + channel.CustomChannelData = customChanBytes + channel.Private = isPrivate(historical) channel.Memo = string(historical.Memo) @@ -4218,20 +4225,41 @@ func (r *rpcServer) fetchWaitingCloseChannels( return nil, 0, err } + customChanBytes, err := encodeCustomChanData(waitingClose) + if err != nil { + return nil, 0, fmt.Errorf("unable to encode "+ + "open chan data: %w", err) + } + + localCommit := waitingClose.LocalCommitment + chanStatus := waitingClose.ChanStatus() channel := &lnrpc.PendingChannelsResponse_PendingChannel{ - RemoteNodePub: hex.EncodeToString(pub), - ChannelPoint: chanPoint.String(), - Capacity: int64(waitingClose.Capacity), - LocalBalance: int64(waitingClose.LocalCommitment.LocalBalance.ToSatoshis()), - RemoteBalance: int64(waitingClose.LocalCommitment.RemoteBalance.ToSatoshis()), - LocalChanReserveSat: int64(waitingClose.LocalChanCfg.ChanReserve), - RemoteChanReserveSat: int64(waitingClose.RemoteChanCfg.ChanReserve), - Initiator: rpcInitiator(waitingClose.IsInitiator), - CommitmentType: rpcCommitmentType(waitingClose.ChanType), + RemoteNodePub: hex.EncodeToString(pub), + ChannelPoint: chanPoint.String(), + Capacity: int64(waitingClose.Capacity), + LocalBalance: int64( + localCommit.LocalBalance.ToSatoshis(), + ), + RemoteBalance: int64( + localCommit.RemoteBalance.ToSatoshis(), + ), + LocalChanReserveSat: int64( + waitingClose.LocalChanCfg.ChanReserve, + ), + RemoteChanReserveSat: int64( + waitingClose.RemoteChanCfg.ChanReserve, + ), + Initiator: rpcInitiator( + waitingClose.IsInitiator, + ), + CommitmentType: rpcCommitmentType( + waitingClose.ChanType, + ), NumForwardingPackages: int64(len(fwdPkgs)), - ChanStatusFlags: waitingClose.ChanStatus().String(), + ChanStatusFlags: chanStatus.String(), Private: isPrivate(waitingClose), Memo: string(waitingClose.Memo), + CustomChannelData: customChanBytes, } var closingTxid, closingTxHex string