lnrpc: add initiator bool to PendingChannel message

This commit is contained in:
carla
2020-03-25 08:40:44 +02:00
parent 4bc7524410
commit fd6b397496
4 changed files with 757 additions and 714 deletions

View File

@@ -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{