lnrpc: expose commitment type on pending open and waiting close channels

This commit is contained in:
Joost Jager 2020-03-30 20:36:38 +02:00
parent 41573004a3
commit baffe156db
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
4 changed files with 790 additions and 755 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1314,6 +1314,11 @@ enum CommitmentType {
been broadcast.
*/
ANCHORS = 2;
/**
Returned when the commitment type isn't known or unavailable.
*/
UNKNOWN_COMMITMENT_TYPE = 999;
}
message Channel {
@ -2087,6 +2092,9 @@ message PendingChannelsResponse {
// True if we initiated opening the channel.
bool initiator = 8;
/// The commitment type used by this channel.
CommitmentType commitment_type = 9;
}
message PendingOpenChannel {

View File

@ -1746,6 +1746,10 @@
"type": "boolean",
"format": "boolean",
"description": "True if we initiated opening the channel."
},
"commitment_type": {
"$ref": "#/definitions/lnrpcCommitmentType",
"description": "/ The commitment type used by this channel."
}
}
},
@ -2523,10 +2527,11 @@
"enum": [
"LEGACY",
"STATIC_REMOTE_KEY",
"ANCHORS"
"ANCHORS",
"UNKNOWN_COMMITMENT_TYPE"
],
"default": "LEGACY",
"description": " - LEGACY: *\nA channel using the legacy commitment format having tweaked to_remote\nkeys.\n - STATIC_REMOTE_KEY: *\nA channel that uses the modern commitment format where the key in the\noutput of the remote party does not change each state. This makes back\nup and recovery easier as when the channel is closed, the funds go\ndirectly to that key.\n - ANCHORS: *\nA channel that uses a commitment format that has anchor outputs on the\ncommitments, allowing fee bumping after a force close transaction has\nbeen broadcast."
"description": " - LEGACY: *\nA channel using the legacy commitment format having tweaked to_remote\nkeys.\n - STATIC_REMOTE_KEY: *\nA channel that uses the modern commitment format where the key in the\noutput of the remote party does not change each state. This makes back\nup and recovery easier as when the channel is closed, the funds go\ndirectly to that key.\n - ANCHORS: *\nA channel that uses a commitment format that has anchor outputs on the\ncommitments, allowing fee bumping after a force close transaction has\nbeen broadcast.\n - UNKNOWN_COMMITMENT_TYPE: *\nReturned when the commitment type isn't known or unavailable."
},
"lnrpcConnectPeerRequest": {
"type": "object",

View File

@ -2738,6 +2738,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
LocalChanReserveSat: int64(pendingChan.LocalChanCfg.ChanReserve),
RemoteChanReserveSat: int64(pendingChan.RemoteChanCfg.ChanReserve),
Initiator: pendingChan.IsInitiator,
CommitmentType: rpcCommitmentType(pendingChan.ChanType),
},
CommitWeight: commitWeight,
CommitFee: int64(localCommitment.CommitFee),
@ -2764,10 +2765,11 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
pub := pendingClose.RemotePub.SerializeCompressed()
chanPoint := pendingClose.ChanPoint
channel := &lnrpc.PendingChannelsResponse_PendingChannel{
RemoteNodePub: hex.EncodeToString(pub),
ChannelPoint: chanPoint.String(),
Capacity: int64(pendingClose.Capacity),
LocalBalance: int64(pendingClose.SettledBalance),
RemoteNodePub: hex.EncodeToString(pub),
ChannelPoint: chanPoint.String(),
Capacity: int64(pendingClose.Capacity),
LocalBalance: int64(pendingClose.SettledBalance),
CommitmentType: lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE,
}
// Lookup the channel in the historical channel bucket to obtain
@ -2786,6 +2788,9 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
case nil:
channel.Initiator = historical.IsInitiator
channel.CommitmentType = rpcCommitmentType(
historical.ChanType,
)
// If the error is non-nil, and not due to older versions of lnd
// not persisting historical channels, return it.
@ -2913,6 +2918,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
LocalChanReserveSat: int64(waitingClose.LocalChanCfg.ChanReserve),
RemoteChanReserveSat: int64(waitingClose.RemoteChanCfg.ChanReserve),
Initiator: waitingClose.IsInitiator,
CommitmentType: rpcCommitmentType(waitingClose.ChanType),
}
waitingCloseResp := &lnrpc.PendingChannelsResponse_WaitingCloseChannel{