lnrpc: move initiator enum out of close summary

Move enum out of CloseSummary struct for more general use. This does
not change the encoding of the enum, and will only cause compile time
errors for existing clients. This enum has not been included in a
release yet, so we can make this move without much disruption.
This commit is contained in:
carla 2020-04-03 09:09:39 +02:00
parent 0512b39f23
commit 2ae61162db
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91
5 changed files with 822 additions and 821 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1483,6 +1483,13 @@ message ListChannelsResponse {
repeated Channel channels = 11;
}
enum Initiator {
INITIATOR_UNKNOWN = 0;
INITIATOR_LOCAL = 1;
INITIATOR_REMOTE = 2;
INITIATOR_BOTH = 3;
}
message ChannelCloseSummary {
/// The outpoint (txid:index) of the funding transaction.
string channel_point = 1;
@ -1523,13 +1530,6 @@ message ChannelCloseSummary {
/// Details on how the channel was closed.
ClosureType close_type = 10;
enum Initiator {
UNKNOWN = 0;
LOCAL = 1;
REMOTE = 2;
BOTH = 3;
}
/**
Open initiator is the party that initiated opening the channel. Note that
this value may be unknown if the channel was closed before we migrated to

View File

@ -1513,16 +1513,6 @@
],
"default": "COOPERATIVE_CLOSE"
},
"ChannelCloseSummaryInitiator": {
"type": "string",
"enum": [
"UNKNOWN",
"LOCAL",
"REMOTE",
"BOTH"
],
"default": "UNKNOWN"
},
"ChannelEventUpdateUpdateType": {
"type": "string",
"enum": [
@ -2233,11 +2223,11 @@
"description": "/ Details on how the channel was closed."
},
"open_initiator": {
"$ref": "#/definitions/ChannelCloseSummaryInitiator",
"$ref": "#/definitions/lnrpcInitiator",
"description": "*\nOpen initiator is the party that initiated opening the channel. Note that\nthis value may be unknown if the channel was closed before we migrated to\nstore open channel information after close."
},
"close_initiator": {
"$ref": "#/definitions/ChannelCloseSummaryInitiator",
"$ref": "#/definitions/lnrpcInitiator",
"description": "*\nClose initiator indicates which party initiated the close. This value will\nbe unknown for channels that were cooperatively closed before we started\ntracking cooperative close initiators. Note that this indicates which party\ninitiated a close, and it is possible for both to initiate cooperative or\nforce closes, although only one party's close will be confirmed on chain."
}
}
@ -3183,6 +3173,16 @@
"lnrpcInitWalletResponse": {
"type": "object"
},
"lnrpcInitiator": {
"type": "string",
"enum": [
"INITIATOR_UNKNOWN",
"INITIATOR_LOCAL",
"INITIATOR_REMOTE",
"INITIATOR_BOTH"
],
"default": "INITIATOR_UNKNOWN"
},
"lnrpcInvoice": {
"type": "object",
"properties": {

View File

@ -6628,7 +6628,7 @@ func subscribeChannelNotifications(ctxb context.Context, t *harnessTest,
// expected type.
func verifyCloseUpdate(chanUpdate *lnrpc.ChannelEventUpdate,
closeType lnrpc.ChannelCloseSummary_ClosureType,
closeInitiator lnrpc.ChannelCloseSummary_Initiator) error {
closeInitiator lnrpc.Initiator) error {
// We should receive one inactive and one closed notification
// for each channel.
@ -6772,7 +6772,7 @@ func testBasicChannelCreationAndUpdates(net *lntest.NetworkHarness, t *harnessTe
// receive the correct channel updates in order.
verifyCloseUpdatesReceived := func(sub channelSubscription,
forceType lnrpc.ChannelCloseSummary_ClosureType,
closeInitiator lnrpc.ChannelCloseSummary_Initiator) error {
closeInitiator lnrpc.Initiator) error {
// Ensure one inactive and one closed notification is received for each
// closed channel.
@ -6818,7 +6818,7 @@ func testBasicChannelCreationAndUpdates(net *lntest.NetworkHarness, t *harnessTe
// close initiator because Alice closed the channels.
if err := verifyCloseUpdatesReceived(bobChanSub,
lnrpc.ChannelCloseSummary_REMOTE_FORCE_CLOSE,
lnrpc.ChannelCloseSummary_REMOTE); err != nil {
lnrpc.Initiator_INITIATOR_REMOTE); err != nil {
t.Fatalf("errored verifying close updates: %v", err)
}
@ -6828,7 +6828,7 @@ func testBasicChannelCreationAndUpdates(net *lntest.NetworkHarness, t *harnessTe
// close initiator because Alice closed the channels.
if err := verifyCloseUpdatesReceived(aliceChanSub,
lnrpc.ChannelCloseSummary_LOCAL_FORCE_CLOSE,
lnrpc.ChannelCloseSummary_LOCAL); err != nil {
lnrpc.Initiator_INITIATOR_LOCAL); err != nil {
t.Fatalf("errored verifying close updates: %v", err)
}
}

View File

@ -3370,8 +3370,8 @@ func (r *rpcServer) createRPCClosedChannel(
var (
closeType lnrpc.ChannelCloseSummary_ClosureType
openInit lnrpc.ChannelCloseSummary_Initiator
closeInitiator lnrpc.ChannelCloseSummary_Initiator
openInit lnrpc.Initiator
closeInitiator lnrpc.Initiator
err error
)
@ -3422,12 +3422,12 @@ func (r *rpcServer) createRPCClosedChannel(
// channel is not present (which indicates that it was closed before we started
// writing channels to the historical close bucket).
func (r *rpcServer) getInitiators(chanPoint *wire.OutPoint) (
lnrpc.ChannelCloseSummary_Initiator,
lnrpc.ChannelCloseSummary_Initiator, error) {
lnrpc.Initiator,
lnrpc.Initiator, error) {
var (
openInitiator = lnrpc.ChannelCloseSummary_UNKNOWN
closeInitiator = lnrpc.ChannelCloseSummary_UNKNOWN
openInitiator = lnrpc.Initiator_INITIATOR_UNKNOWN
closeInitiator = lnrpc.Initiator_INITIATOR_UNKNOWN
)
// To get the close initiator for cooperative closes, we need
@ -3452,9 +3452,9 @@ func (r *rpcServer) getInitiators(chanPoint *wire.OutPoint) (
// If we successfully looked up the channel, determine initiator based
// on channels status.
if histChan.IsInitiator {
openInitiator = lnrpc.ChannelCloseSummary_LOCAL
openInitiator = lnrpc.Initiator_INITIATOR_LOCAL
} else {
openInitiator = lnrpc.ChannelCloseSummary_REMOTE
openInitiator = lnrpc.Initiator_INITIATOR_REMOTE
}
localInit := histChan.HasChanStatus(
@ -3470,13 +3470,13 @@ func (r *rpcServer) getInitiators(chanPoint *wire.OutPoint) (
// We return the initiator as both in this case to provide full
// information about the close.
case localInit && remoteInit:
closeInitiator = lnrpc.ChannelCloseSummary_BOTH
closeInitiator = lnrpc.Initiator_INITIATOR_BOTH
case localInit:
closeInitiator = lnrpc.ChannelCloseSummary_LOCAL
closeInitiator = lnrpc.Initiator_INITIATOR_LOCAL
case remoteInit:
closeInitiator = lnrpc.ChannelCloseSummary_REMOTE
closeInitiator = lnrpc.Initiator_INITIATOR_REMOTE
}
return openInitiator, closeInitiator, nil