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.
This commit is contained in:
Oliver Gugger committed 2025-03-27 12:38:49 -05:00
1 parent bab5cabd90
commit 82b7891e2d
1 file changed
+38 -10
+38 -10
View File
@@ -4028,6 +4028,13 @@ func (r *rpcServer) fetchPendingForceCloseChannels() (pendingForceClose,
historical.LocalCommitment.RemoteBalance.ToSatoshis(), 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.Private = isPrivate(historical)
channel.Memo = string(historical.Memo) channel.Memo = string(historical.Memo)
@@ -4218,20 +4225,41 @@ func (r *rpcServer) fetchWaitingCloseChannels(
return nil, 0, err 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{ channel := &lnrpc.PendingChannelsResponse_PendingChannel{
RemoteNodePub: hex.EncodeToString(pub), RemoteNodePub: hex.EncodeToString(pub),
ChannelPoint: chanPoint.String(), ChannelPoint: chanPoint.String(),
Capacity: int64(waitingClose.Capacity), Capacity: int64(waitingClose.Capacity),
LocalBalance: int64(waitingClose.LocalCommitment.LocalBalance.ToSatoshis()), LocalBalance: int64(
RemoteBalance: int64(waitingClose.LocalCommitment.RemoteBalance.ToSatoshis()), localCommit.LocalBalance.ToSatoshis(),
LocalChanReserveSat: int64(waitingClose.LocalChanCfg.ChanReserve), ),
RemoteChanReserveSat: int64(waitingClose.RemoteChanCfg.ChanReserve), RemoteBalance: int64(
Initiator: rpcInitiator(waitingClose.IsInitiator), localCommit.RemoteBalance.ToSatoshis(),
CommitmentType: rpcCommitmentType(waitingClose.ChanType), ),
LocalChanReserveSat: int64(
waitingClose.LocalChanCfg.ChanReserve,
),
RemoteChanReserveSat: int64(
waitingClose.RemoteChanCfg.ChanReserve,
),
Initiator: rpcInitiator(
waitingClose.IsInitiator,
),
CommitmentType: rpcCommitmentType(
waitingClose.ChanType,
),
NumForwardingPackages: int64(len(fwdPkgs)), NumForwardingPackages: int64(len(fwdPkgs)),
ChanStatusFlags: waitingClose.ChanStatus().String(), ChanStatusFlags: chanStatus.String(),
Private: isPrivate(waitingClose), Private: isPrivate(waitingClose),
Memo: string(waitingClose.Memo), Memo: string(waitingClose.Memo),
CustomChannelData: customChanBytes,
} }
var closingTxid, closingTxHex string var closingTxid, closingTxHex string