Skip to content

Commit d4ef548

Browse files
committed
looprpc: authorize recovery restore calls
Grant the manual recovery RPC the auth-write and static-address loop-in permissions it needs so loopd can restore local L402 material and static-address state through the authenticated client connection.
1 parent bafd8f5 commit d4ef548

8 files changed

Lines changed: 716 additions & 288 deletions

File tree

looprpc/client.pb.go

Lines changed: 442 additions & 288 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

looprpc/client.pb.gw.go

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

looprpc/client.proto

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ service SwapClient {
102102
*/
103103
rpc FetchL402Token (FetchL402TokenRequest) returns (FetchL402TokenResponse);
104104

105+
/* loop: `recover`
106+
Recover restores the local static-address and L402 state from an encrypted
107+
local backup file.
108+
*/
109+
rpc Recover (RecoverRequest) returns (RecoverResponse);
110+
105111
/* loop: `getinfo`
106112
GetInfo gets basic information about the loop daemon.
107113
*/
@@ -1060,6 +1066,48 @@ message FetchL402TokenRequest {
10601066
message FetchL402TokenResponse {
10611067
}
10621068

1069+
message RecoverRequest {
1070+
/*
1071+
Optional path to the encrypted backup file. If omitted, loopd restores from
1072+
the most recent immutable L402 recovery backup in the active network data
1073+
directory.
1074+
*/
1075+
string backup_file = 1;
1076+
}
1077+
1078+
message RecoverResponse {
1079+
/*
1080+
The backup file that was restored.
1081+
*/
1082+
string backup_file = 1;
1083+
1084+
/*
1085+
Whether a paid L402 token was restored into the local token store.
1086+
*/
1087+
bool restored_l402 = 2;
1088+
1089+
/*
1090+
Whether static-address state was restored into loopd and lnd.
1091+
*/
1092+
bool restored_static_address = 3;
1093+
1094+
/*
1095+
The restored static address, if any.
1096+
*/
1097+
string static_address = 4;
1098+
1099+
/*
1100+
The number of deposits found during best-effort reconciliation.
1101+
*/
1102+
uint32 num_deposits_found = 5;
1103+
1104+
/*
1105+
Best-effort deposit reconciliation error text, if reconciliation failed
1106+
after state restore completed.
1107+
*/
1108+
string deposit_reconciliation_error = 6;
1109+
}
1110+
10631111
message L402Token {
10641112
/*
10651113
The base macaroon that was baked by the auth server.

looprpc/client.swagger.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,39 @@
868868
]
869869
}
870870
},
871+
"/v1/recover": {
872+
"post": {
873+
"summary": "loop: `recover`\nRecover restores the local static-address and L402 state from an encrypted\nlocal backup file.",
874+
"operationId": "SwapClient_Recover",
875+
"responses": {
876+
"200": {
877+
"description": "A successful response.",
878+
"schema": {
879+
"$ref": "#/definitions/looprpcRecoverResponse"
880+
}
881+
},
882+
"default": {
883+
"description": "An unexpected error response.",
884+
"schema": {
885+
"$ref": "#/definitions/rpcStatus"
886+
}
887+
}
888+
},
889+
"parameters": [
890+
{
891+
"name": "body",
892+
"in": "body",
893+
"required": true,
894+
"schema": {
895+
"$ref": "#/definitions/looprpcRecoverRequest"
896+
}
897+
}
898+
],
899+
"tags": [
900+
"SwapClient"
901+
]
902+
}
903+
},
871904
"/v1/staticaddr": {
872905
"post": {
873906
"summary": "loop: `static newstaticaddress`\nNewStaticAddress requests a new static address for loop-ins from the server.",
@@ -2599,6 +2632,45 @@
25992632
"type": "object",
26002633
"description": "PublishSucceeded is returned by SweepHtlc if publishing was requested in\nSweepHtlcRequest and it succeeded."
26012634
},
2635+
"looprpcRecoverRequest": {
2636+
"type": "object",
2637+
"properties": {
2638+
"backup_file": {
2639+
"type": "string",
2640+
"description": "Optional path to the encrypted backup file. If omitted, loopd restores from\nthe most recent immutable L402 recovery backup in the active network data\ndirectory."
2641+
}
2642+
}
2643+
},
2644+
"looprpcRecoverResponse": {
2645+
"type": "object",
2646+
"properties": {
2647+
"backup_file": {
2648+
"type": "string",
2649+
"description": "The backup file that was restored."
2650+
},
2651+
"restored_l402": {
2652+
"type": "boolean",
2653+
"description": "Whether a paid L402 token was restored into the local token store."
2654+
},
2655+
"restored_static_address": {
2656+
"type": "boolean",
2657+
"description": "Whether static-address state was restored into loopd and lnd."
2658+
},
2659+
"static_address": {
2660+
"type": "string",
2661+
"description": "The restored static address, if any."
2662+
},
2663+
"num_deposits_found": {
2664+
"type": "integer",
2665+
"format": "int64",
2666+
"description": "The number of deposits found during best-effort reconciliation."
2667+
},
2668+
"deposit_reconciliation_error": {
2669+
"type": "string",
2670+
"description": "Best-effort deposit reconciliation error text, if reconciliation failed\nafter state restore completed."
2671+
}
2672+
}
2673+
},
26022674
"looprpcRouteHint": {
26032675
"type": "object",
26042676
"properties": {

looprpc/client.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ http:
3333
get: "/v1/l402/tokens"
3434
additional_bindings:
3535
- get: "/v1/lsat/tokens"
36+
- selector: looprpc.SwapClient.Recover
37+
post: "/v1/recover"
38+
body: "*"
3639
- selector: looprpc.SwapClient.GetLiquidityParams
3740
get: "/v1/liquidity/params"
3841
- selector: looprpc.SwapClient.SetLiquidityParams

looprpc/client_grpc.pb.go

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

looprpc/perms.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ var RequiredPermissions = map[string][]bakery.Op{
151151
Entity: "auth",
152152
Action: "write",
153153
}},
154+
"/looprpc.SwapClient/Recover": {{
155+
Entity: "auth",
156+
Action: "write",
157+
}, {
158+
Entity: "loop",
159+
Action: "in",
160+
}},
154161
"/looprpc.SwapClient/SuggestSwaps": {{
155162
Entity: "suggestions",
156163
Action: "read",

looprpc/swapclient.pb.json.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)