mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
rpc: add new commitment_type field to OpenChannelRequest
This field will be examined later down the stack along with the set of feature bits to determine if explicit channel commitment type negotiation is possible or not.
This commit is contained in:
parent
d0779e2ec2
commit
5a9f499dd5
@ -240,6 +240,11 @@ type InitFundingMsg struct {
|
||||
// protocol.
|
||||
PendingChanID [32]byte
|
||||
|
||||
// ChannelType allows the caller to use an explicit channel type for the
|
||||
// funding negotiation. This type will only be observed if BOTH sides
|
||||
// support explicit channel type negotiation.
|
||||
ChannelType *lnwire.ChannelType
|
||||
|
||||
// Updates is a channel which updates to the opening status of the channel
|
||||
// are sent on.
|
||||
Updates chan *lnrpc.OpenStatusUpdate
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1115,11 +1115,16 @@ message HTLC {
|
||||
}
|
||||
|
||||
enum CommitmentType {
|
||||
/*
|
||||
Returned when the commitment type isn't known or unavailable.
|
||||
*/
|
||||
UNKNOWN_COMMITMENT_TYPE = 0;
|
||||
|
||||
/*
|
||||
A channel using the legacy commitment format having tweaked to_remote
|
||||
keys.
|
||||
*/
|
||||
LEGACY = 0;
|
||||
LEGACY = 1;
|
||||
|
||||
/*
|
||||
A channel that uses the modern commitment format where the key in the
|
||||
@ -1127,19 +1132,14 @@ enum CommitmentType {
|
||||
up and recovery easier as when the channel is closed, the funds go
|
||||
directly to that key.
|
||||
*/
|
||||
STATIC_REMOTE_KEY = 1;
|
||||
STATIC_REMOTE_KEY = 2;
|
||||
|
||||
/*
|
||||
A channel that uses a commitment format that has anchor outputs on the
|
||||
commitments, allowing fee bumping after a force close transaction has
|
||||
been broadcast.
|
||||
*/
|
||||
ANCHORS = 2;
|
||||
|
||||
/*
|
||||
Returned when the commitment type isn't known or unavailable.
|
||||
*/
|
||||
UNKNOWN_COMMITMENT_TYPE = 999;
|
||||
ANCHORS = 3;
|
||||
}
|
||||
|
||||
message ChannelConstraints {
|
||||
@ -1867,6 +1867,12 @@ message OpenChannelRequest {
|
||||
transaction.
|
||||
*/
|
||||
uint32 max_local_csv = 17;
|
||||
|
||||
/*
|
||||
The explicit commitment type to use. Note this field will only be used if
|
||||
the remote peer supports explicit channel negotiation.
|
||||
*/
|
||||
CommitmentType commitment_type = 18;
|
||||
}
|
||||
message OpenStatusUpdate {
|
||||
oneof update {
|
||||
|
@ -3502,13 +3502,13 @@
|
||||
"lnrpcCommitmentType": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"UNKNOWN_COMMITMENT_TYPE",
|
||||
"LEGACY",
|
||||
"STATIC_REMOTE_KEY",
|
||||
"ANCHORS",
|
||||
"UNKNOWN_COMMITMENT_TYPE"
|
||||
"ANCHORS"
|
||||
],
|
||||
"default": "LEGACY",
|
||||
"description": " - LEGACY: A channel using the legacy commitment format having tweaked to_remote\nkeys.\n - STATIC_REMOTE_KEY: A 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: A 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: Returned when the commitment type isn't known or unavailable."
|
||||
"default": "UNKNOWN_COMMITMENT_TYPE",
|
||||
"description": " - UNKNOWN_COMMITMENT_TYPE: Returned when the commitment type isn't known or unavailable.\n - LEGACY: A channel using the legacy commitment format having tweaked to_remote\nkeys.\n - STATIC_REMOTE_KEY: A 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: A channel that uses a commitment format that has anchor outputs on the\ncommitments, allowing fee bumping after a force close transaction has\nbeen broadcast."
|
||||
},
|
||||
"lnrpcConnectPeerRequest": {
|
||||
"type": "object",
|
||||
@ -4923,6 +4923,10 @@
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "Max local csv is the maximum csv delay we will allow for our own commitment\ntransaction."
|
||||
},
|
||||
"commitment_type": {
|
||||
"$ref": "#/definitions/lnrpcCommitmentType",
|
||||
"description": "The explicit commitment type to use. Note this field will only be used if\nthe remote peer supports explicit channel negotiation."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
28
rpcserver.go
28
rpcserver.go
@ -1912,6 +1912,33 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
||||
err)
|
||||
}
|
||||
|
||||
var channelType *lnwire.ChannelType
|
||||
switch in.CommitmentType {
|
||||
case lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE:
|
||||
break
|
||||
|
||||
case lnrpc.CommitmentType_LEGACY:
|
||||
channelType = new(lnwire.ChannelType)
|
||||
*channelType = lnwire.ChannelType(*lnwire.NewRawFeatureVector())
|
||||
|
||||
case lnrpc.CommitmentType_STATIC_REMOTE_KEY:
|
||||
channelType = new(lnwire.ChannelType)
|
||||
*channelType = lnwire.ChannelType(*lnwire.NewRawFeatureVector(
|
||||
lnwire.StaticRemoteKeyRequired,
|
||||
))
|
||||
|
||||
case lnrpc.CommitmentType_ANCHORS:
|
||||
channelType = new(lnwire.ChannelType)
|
||||
*channelType = lnwire.ChannelType(*lnwire.NewRawFeatureVector(
|
||||
lnwire.StaticRemoteKeyRequired,
|
||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||
))
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unhandled request channel type %v",
|
||||
in.CommitmentType)
|
||||
}
|
||||
|
||||
// Instruct the server to trigger the necessary events to attempt to
|
||||
// open a new channel. A stream is returned in place, this stream will
|
||||
// be used to consume updates of the state of the pending channel.
|
||||
@ -1929,6 +1956,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
||||
MaxValueInFlight: maxValue,
|
||||
MaxHtlcs: maxHtlcs,
|
||||
MaxLocalCsv: uint16(in.MaxLocalCsv),
|
||||
ChannelType: channelType,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user