mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-04 18:01:57 +01:00
lnrpc: add initiator bool to PendingChannel message
This commit is contained in:
25
rpcserver.go
25
rpcserver.go
@@ -2665,6 +2665,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
RemoteBalance: int64(localCommitment.RemoteBalance.ToSatoshis()),
|
||||
LocalChanReserveSat: int64(pendingChan.LocalChanCfg.ChanReserve),
|
||||
RemoteChanReserveSat: int64(pendingChan.RemoteChanCfg.ChanReserve),
|
||||
Initiator: pendingChan.IsInitiator,
|
||||
},
|
||||
CommitWeight: commitWeight,
|
||||
CommitFee: int64(localCommitment.CommitFee),
|
||||
@@ -2697,6 +2698,29 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
LocalBalance: int64(pendingClose.SettledBalance),
|
||||
}
|
||||
|
||||
// Lookup the channel in the historical channel bucket to obtain
|
||||
// initiator information. If the historical channel bucket was
|
||||
// not found, or the channel itself, this channel was closed
|
||||
// in a version before we started persisting historical
|
||||
// channels, so we silence the error.
|
||||
historical, err := r.server.chanDB.FetchHistoricalChannel(
|
||||
&pendingClose.ChanPoint,
|
||||
)
|
||||
switch err {
|
||||
// If the channel was closed in a version that did not record
|
||||
// historical channels, ignore the error.
|
||||
case channeldb.ErrNoHistoricalBucket:
|
||||
case channeldb.ErrChannelNotFound:
|
||||
|
||||
case nil:
|
||||
channel.Initiator = historical.IsInitiator
|
||||
|
||||
// If the error is non-nil, and not due to older versions of lnd
|
||||
// not persisting historical channels, return it.
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
|
||||
closeTXID := pendingClose.ClosingTXID.String()
|
||||
|
||||
switch pendingClose.CloseType {
|
||||
@@ -2813,6 +2837,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
RemoteBalance: int64(waitingClose.LocalCommitment.RemoteBalance.ToSatoshis()),
|
||||
LocalChanReserveSat: int64(waitingClose.LocalChanCfg.ChanReserve),
|
||||
RemoteChanReserveSat: int64(waitingClose.RemoteChanCfg.ChanReserve),
|
||||
Initiator: waitingClose.IsInitiator,
|
||||
}
|
||||
|
||||
waitingCloseResp := &lnrpc.PendingChannelsResponse_WaitingCloseChannel{
|
||||
|
||||
Reference in New Issue
Block a user