mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
lnrpc: add initiator bool to PendingChannel message
This commit is contained in:
parent
4bc7524410
commit
fd6b397496
1438
lnrpc/rpc.pb.go
1438
lnrpc/rpc.pb.go
File diff suppressed because it is too large
Load Diff
@ -1973,6 +1973,9 @@ message PendingChannelsResponse {
|
||||
balance.
|
||||
*/
|
||||
int64 remote_chan_reserve_sat = 7;
|
||||
|
||||
// True if we initiated opening the channel.
|
||||
bool initiator = 8;
|
||||
}
|
||||
|
||||
message PendingOpenChannel {
|
||||
|
@ -1692,6 +1692,11 @@
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "*\nThe minimum satoshis the other node is required to reserve in its\nbalance."
|
||||
},
|
||||
"initiator": {
|
||||
"type": "boolean",
|
||||
"format": "boolean",
|
||||
"description": "True if we initiated opening the channel."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
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{
|
||||
|
Loading…
Reference in New Issue
Block a user