rpcserver+lnrpc+lncli: add AbandonChannel rpc call

Using AbandonChannel, a channel can be abandoned. This means
removing all state without any on-chain or off-chain action.
A close summary is the only thing that is stored in the db after
abandoning.

A specific close type Abandoned is added. Abandoned channels
can be retrieved via the ClosedChannels RPC.
This commit is contained in:
Joost Jager committed 2018-09-18 12:20:27 -07:00
1 parent 3b6f7fdb83
commit ab67b9a4de
10 files changed
+816 -448

No files matched your search

+495 -408
View File
File diff suppressed because it is too large. Load diff
+79
View File
@@ -301,6 +301,52 @@ func request_Lightning_CloseChannel_0(ctx context.Context, marshaler runtime.Mar
}
var (
filter_Lightning_AbandonChannel_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_point": 0, "funding_txid_str": 1, "output_index": 2}, Base: []int{1, 1, 1, 2, 0, 0}, Check: []int{0, 1, 2, 2, 3, 4}}
)
func request_Lightning_AbandonChannel_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq AbandonChannelRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["channel_point.funding_txid_str"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_point.funding_txid_str")
}
err = runtime.PopulateFieldFromPath(&protoReq, "channel_point.funding_txid_str", val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_point.funding_txid_str", err)
}
val, ok = pathParams["channel_point.output_index"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_point.output_index")
}
err = runtime.PopulateFieldFromPath(&protoReq, "channel_point.output_index", val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_point.output_index", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Lightning_AbandonChannel_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.AbandonChannel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_SendPaymentSync_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq SendRequest
var metadata runtime.ServerMetadata
@@ -1220,6 +1266,35 @@ func RegisterLightningHandler(ctx context.Context, mux *runtime.ServeMux, conn *
})
mux.Handle("DELETE", pattern_Lightning_AbandonChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Lightning_AbandonChannel_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Lightning_AbandonChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Lightning_SendPaymentSync_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@@ -1745,6 +1820,8 @@ var (
pattern_Lightning_CloseChannel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "channels", "channel_point.funding_txid_str", "channel_point.output_index"}, ""))
pattern_Lightning_AbandonChannel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "channels", "channel_point.funding_txid_str", "channel_point.output_index"}, ""))
pattern_Lightning_SendPaymentSync_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "channels", "transactions"}, ""))
pattern_Lightning_SendToRouteSync_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "channels", "transactions", "route"}, ""))
@@ -1809,6 +1886,8 @@ var (
forward_Lightning_CloseChannel_0 = runtime.ForwardResponseStream
forward_Lightning_AbandonChannel_0 = runtime.ForwardResponseMessage
forward_Lightning_SendPaymentSync_0 = runtime.ForwardResponseMessage
forward_Lightning_SendToRouteSync_0 = runtime.ForwardResponseMessage
+23
View File
@@ -389,6 +389,19 @@ service Lightning {
};
}
/** lncli: `abandonchannel`
AbandonChannel removes all channel state from the database except for a
close summary. This method can be used to get rid of permanently unusable
channels due to bugs fixed in newer versions of lnd. Only available
when in debug builds of lnd.
*/
rpc AbandonChannel (AbandonChannelRequest) returns (AbandonChannelResponse) {
option (google.api.http) = {
delete: "/v1/channels/{channel_point.funding_txid_str}/{channel_point.output_index}"
};
}
/** lncli: `sendpayment`
SendPayment dispatches a bi-directional streaming RPC for sending payments
through the Lightning Network. A single RPC invocation creates a persistent
@@ -991,6 +1004,7 @@ message ChannelCloseSummary {
REMOTE_FORCE_CLOSE = 2;
BREACH_CLOSE = 3;
FUNDING_CANCELED = 4;
ABANDONED = 5;
}
/// Details on how the channel was closed.
@@ -1003,6 +1017,7 @@ message ClosedChannelsRequest {
bool remote_force = 3;
bool breach = 4;
bool funding_canceled = 5;
bool abandoned = 6;
}
message ClosedChannelsResponse {
@@ -1820,6 +1835,14 @@ message DeleteAllPaymentsRequest {
message DeleteAllPaymentsResponse {
}
message AbandonChannelRequest {
ChannelPoint channel_point = 1;
}
message AbandonChannelResponse {
}
message DebugLevelRequest {
bool show = 1;
string level_spec = 2;
+16 -5
View File
@@ -195,6 +195,13 @@
"required": false,
"type": "boolean",
"format": "boolean"
},
{
"name": "abandoned",
"in": "query",
"required": false,
"type": "boolean",
"format": "boolean"
}
],
"tags": [
@@ -275,13 +282,13 @@
},
"/v1/channels/{channel_point.funding_txid_str}/{channel_point.output_index}": {
"delete": {
"summary": "* lncli: `closechannel`\nCloseChannel attempts to close an active channel identified by its channel\noutpoint (ChannelPoint). The actions of this method can additionally be\naugmented to attempt a force close after a timeout period in the case of an\ninactive peer. If a non-force close (cooperative closure) is requested,\nthen the user can specify either a target number of blocks until the\nclosure transaction is confirmed, or a manual fee rate. If neither are\nspecified, then a default lax, block confirmation target is used.",
"operationId": "CloseChannel",
"summary": "* lncli: `abandonchannel`\nAbandonChannel removes all channel state from the database except for a\nclose summary. This method can be used to get rid of permanently unusable\nchannels due to bugs fixed in newer versions of lnd. Only available\nwhen in debug builds of lnd.",
"operationId": "AbandonChannel",
"responses": {
"200": {
"description": "(streaming responses)",
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcCloseStatusUpdate"
"$ref": "#/definitions/lnrpcAbandonChannelResponse"
}
}
},
@@ -970,7 +977,8 @@
"LOCAL_FORCE_CLOSE",
"REMOTE_FORCE_CLOSE",
"BREACH_CLOSE",
"FUNDING_CANCELED"
"FUNDING_CANCELED",
"ABANDONED"
],
"default": "COOPERATIVE_CLOSE"
},
@@ -1092,6 +1100,9 @@
}
}
},
"lnrpcAbandonChannelResponse": {
"type": "object"
},
"lnrpcAddInvoiceResponse": {
"type": "object",
"properties": {