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; repeated Channel channels = 11;
} }
enum Initiator {
INITIATOR_UNKNOWN = 0;
INITIATOR_LOCAL = 1;
INITIATOR_REMOTE = 2;
INITIATOR_BOTH = 3;
}
message ChannelCloseSummary { message ChannelCloseSummary {
/// The outpoint (txid:index) of the funding transaction. /// The outpoint (txid:index) of the funding transaction.
string channel_point = 1; string channel_point = 1;
@ -1523,13 +1530,6 @@ message ChannelCloseSummary {
/// Details on how the channel was closed. /// Details on how the channel was closed.
ClosureType close_type = 10; 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 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 this value may be unknown if the channel was closed before we migrated to

View File

@ -1513,16 +1513,6 @@
], ],
"default": "COOPERATIVE_CLOSE" "default": "COOPERATIVE_CLOSE"
}, },
"ChannelCloseSummaryInitiator": {
"type": "string",
"enum": [
"UNKNOWN",
"LOCAL",
"REMOTE",
"BOTH"
],
"default": "UNKNOWN"
},
"ChannelEventUpdateUpdateType": { "ChannelEventUpdateUpdateType": {
"type": "string", "type": "string",
"enum": [ "enum": [
@ -2233,11 +2223,11 @@
"description": "/ Details on how the channel was closed." "description": "/ Details on how the channel was closed."
}, },
"open_initiator": { "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." "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": { "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." "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": { "lnrpcInitWalletResponse": {
"type": "object" "type": "object"
}, },
"lnrpcInitiator": {
"type": "string",
"enum": [
"INITIATOR_UNKNOWN",
"INITIATOR_LOCAL",
"INITIATOR_REMOTE",
"INITIATOR_BOTH"
],
"default": "INITIATOR_UNKNOWN"
},
"lnrpcInvoice": { "lnrpcInvoice": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

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

View File

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