multi: add a rpc endpoint to track the recovery process

This commit is contained in:
yyforyongyu committed 2020-06-25 15:49:54 +08:00
1 parent c1ef5bb908
commit 987edc9d81
17 files changed
+1182 -613

No files matched your search

+2
View File
@@ -55,6 +55,8 @@ description):
* Lists all available connected peers.
* GetInfo
* Returns basic data concerning the daemon.
* GetRecoveryInfo
* Returns information about recovery process.
* PendingChannels
* List the number of pending (not fully confirmed) channels.
* ListChannels
+2
View File
@@ -41,6 +41,8 @@ http:
get: "/v1/peers/subscribe"
- selector: lnrpc.Lightning.GetInfo
get: "/v1/getinfo"
- selector: lnrpc.Lightning.GetRecoveryInfo
get: "/v1/getrecoveryinfo"
- selector: lnrpc.Lightning.PendingChannels
get: "/v1/channels/pending"
- selector: lnrpc.Lightning.ListChannels
+2 -2
View File
@@ -1876,8 +1876,8 @@ func (m *ForwardHtlcInterceptRequest) GetExpiry() uint32 {
}
//*
//ForwardHtlcInterceptResponse enables the caller to resolve a previously hold forward.
//The caller can choose either to:
//ForwardHtlcInterceptResponse enables the caller to resolve a previously hold
//forward. The caller can choose either to:
//- `Resume`: Execute the default behavior (usually forward).
//- `Reject`: Fail the htlc backwards.
//- `Settle`: Settle this htlc with a given preimage.
+9 -9
View File
@@ -98,7 +98,7 @@ service Router {
rpc TrackPayment (TrackPaymentRequest) returns (stream PaymentStatus) {
option deprecated = true;
}
/**
HtlcInterceptor dispatches a bi-directional streaming RPC in which
Forwarded HTLC requests are sent to the client and the client responds with
@@ -106,7 +106,8 @@ service Router {
In case of interception, the htlc can be either settled, cancelled or
resumed later by using the ResolveHoldForward endpoint.
*/
rpc HtlcInterceptor (stream ForwardHtlcInterceptResponse) returns (stream ForwardHtlcInterceptRequest);
rpc HtlcInterceptor (stream ForwardHtlcInterceptResponse)
returns (stream ForwardHtlcInterceptRequest);
}
message SendPaymentRequest {
@@ -589,7 +590,7 @@ message PaymentStatus {
repeated lnrpc.HTLCAttempt htlcs = 4;
}
message CircuitKey {
message CircuitKey {
/// The id of the channel that the is part of this circuit.
uint64 chan_id = 1;
@@ -618,14 +619,14 @@ message ForwardHtlcInterceptRequest {
}
/**
ForwardHtlcInterceptResponse enables the caller to resolve a previously hold forward.
The caller can choose either to:
ForwardHtlcInterceptResponse enables the caller to resolve a previously hold
forward. The caller can choose either to:
- `Resume`: Execute the default behavior (usually forward).
- `Reject`: Fail the htlc backwards.
- `Settle`: Settle this htlc with a given preimage.
*/
message ForwardHtlcInterceptResponse {
/**
/**
The key of this forwarded htlc. It defines the incoming channel id and
the index in this channel.
*/
@@ -638,9 +639,8 @@ message ForwardHtlcInterceptResponse {
bytes preimage = 3;
}
enum ResolveHoldForwardAction {
enum ResolveHoldForwardAction {
SETTLE = 0;
FAIL = 1;
RESUME = 2;
RESUME = 2;
}
+740 -601
View File
File diff suppressed because it is too large. Load diff
+62
View File
@@ -519,6 +519,24 @@ func local_request_Lightning_GetInfo_0(ctx context.Context, marshaler runtime.Ma
}
func request_Lightning_GetRecoveryInfo_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetRecoveryInfoRequest
var metadata runtime.ServerMetadata
msg, err := client.GetRecoveryInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Lightning_GetRecoveryInfo_0(ctx context.Context, marshaler runtime.Marshaler, server LightningServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetRecoveryInfoRequest
var metadata runtime.ServerMetadata
msg, err := server.GetRecoveryInfo(ctx, &protoReq)
return msg, metadata, err
}
func request_Lightning_PendingChannels_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq PendingChannelsRequest
var metadata runtime.ServerMetadata
@@ -2194,6 +2212,26 @@ func RegisterLightningHandlerServer(ctx context.Context, mux *runtime.ServeMux,
})
mux.Handle("GET", pattern_Lightning_GetRecoveryInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Lightning_GetRecoveryInfo_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Lightning_GetRecoveryInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_PendingChannels_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -3197,6 +3235,26 @@ func RegisterLightningHandlerClient(ctx context.Context, mux *runtime.ServeMux,
})
mux.Handle("GET", pattern_Lightning_GetRecoveryInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
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_GetRecoveryInfo_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_GetRecoveryInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_PendingChannels_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -3953,6 +4011,8 @@ var (
pattern_Lightning_GetInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getinfo"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Lightning_GetRecoveryInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getrecoveryinfo"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Lightning_PendingChannels_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "channels", "pending"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Lightning_ListChannels_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "channels"}, "", runtime.AssumeColonVerbOpt(true)))
@@ -4059,6 +4119,8 @@ var (
forward_Lightning_GetInfo_0 = runtime.ForwardResponseMessage
forward_Lightning_GetRecoveryInfo_0 = runtime.ForwardResponseMessage
forward_Lightning_PendingChannels_0 = runtime.ForwardResponseMessage
forward_Lightning_ListChannels_0 = runtime.ForwardResponseMessage
+21
View File
@@ -140,6 +140,14 @@ service Lightning {
*/
rpc GetInfo (GetInfoRequest) returns (GetInfoResponse);
/** lncli: `getrecoveryinfo`
GetRecoveryInfo returns information concerning the recovery mode including
whether it's in a recovery mode, whether the recovery is finished, and the
progress made so far.
*/
rpc GetRecoveryInfo (GetRecoveryInfoRequest)
returns (GetRecoveryInfoResponse);
// TODO(roasbeef): merge with below with bool?
/* lncli: `pendingchannels`
PendingChannels returns a list of all the channels that are currently
@@ -1381,6 +1389,19 @@ message GetInfoResponse {
map<uint32, Feature> features = 19;
}
message GetRecoveryInfoRequest {
}
message GetRecoveryInfoResponse {
// Whether the wallet is in recovery mode
bool recovery_mode = 1;
// Whether the wallet recovery progress is finished
bool recovery_finished = 2;
// The recovery progress, ranging from 0 to 1.
double progress = 3;
}
message Chain {
// The blockchain the node is on (eg bitcoin, litecoin)
string chain = 1;
+43
View File
@@ -829,6 +829,29 @@
]
}
},
"/v1/getrecoveryinfo": {
"get": {
"summary": "* lncli: `getrecoveryinfo`\nGetRecoveryInfo returns information concerning the recovery mode including\nwhether it's in a recovery mode, whether the recovery is finished, and the\nprogress made so far.",
"operationId": "GetRecoveryInfo",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/lnrpcGetRecoveryInfoResponse"
}
},
"default": {
"description": "An unexpected error response",
"schema": {
"$ref": "#/definitions/runtimeError"
}
}
},
"tags": [
"Lightning"
]
}
},
"/v1/graph": {
"get": {
"summary": "lncli: `describegraph`\nDescribeGraph returns a description of the latest graph state from the\npoint of view of the node. The graph information is partitioned into two\ncomponents: all the nodes/vertexes, and all the edges that connect the\nvertexes themselves. As this is a directed graph, the edges also contain\nthe node directional specific routing policy which includes: the time lock\ndelta, fee information, etc.",
@@ -3530,6 +3553,26 @@
}
}
},
"lnrpcGetRecoveryInfoResponse": {
"type": "object",
"properties": {
"recovery_mode": {
"type": "boolean",
"format": "boolean",
"title": "Whether the wallet is in recovery mode"
},
"recovery_finished": {
"type": "boolean",
"format": "boolean",
"title": "Whether the wallet recovery progress is finished"
},
"progress": {
"type": "number",
"format": "double",
"description": "The recovery progress, ranging from 0 to 1."
}
}
},
"lnrpcGraphTopologyUpdate": {
"type": "object",
"properties": {