Skip to content

Commit 987edc9

Browse files
committed
multi: add a rpc endpoint to track the recovery process
1 parent c1ef5bb commit 987edc9

17 files changed

+1182
-613
lines changed

cmd/lncli/commands.go

+21
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,27 @@ func getInfo(ctx *cli.Context) error {
17291729
return nil
17301730
}
17311731

1732+
var getRecoveryInfoCommand = cli.Command{
1733+
Name: "getrecoveryinfo",
1734+
Usage: "Display information about an ongoing recovery attempt.",
1735+
Action: actionDecorator(getRecoveryInfo),
1736+
}
1737+
1738+
func getRecoveryInfo(ctx *cli.Context) error {
1739+
ctxb := context.Background()
1740+
client, cleanUp := getClient(ctx)
1741+
defer cleanUp()
1742+
1743+
req := &lnrpc.GetRecoveryInfoRequest{}
1744+
resp, err := client.GetRecoveryInfo(ctxb, req)
1745+
if err != nil {
1746+
return err
1747+
}
1748+
1749+
printRespJSON(resp)
1750+
return nil
1751+
}
1752+
17321753
var pendingChannelsCommand = cli.Command{
17331754
Name: "pendingchannels",
17341755
Category: "Channels",

cmd/lncli/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ func main() {
271271
walletBalanceCommand,
272272
channelBalanceCommand,
273273
getInfoCommand,
274+
getRecoveryInfoCommand,
274275
pendingChannelsCommand,
275276
sendPaymentCommand,
276277
payInvoiceCommand,

docs/recovery.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,15 @@ That final line indicates the rescan is complete! If not all funds have
164164
appeared, then the user may need to _repeat_ the process with a higher recovery
165165
window. Depending on how old the wallet is (the cipher seed stores the wallet's
166166
birthday!) and how many addresses were used, the rescan may take anywhere from
167-
a few minutes to a few hours.
167+
a few minutes to a few hours. To track the recovery progress, one can use the
168+
command `lncli getrecoveryinfo`. When finished, the following is returned,
169+
```
170+
{
171+
"recovery_mode": true,
172+
"recovery_finished": true,
173+
"progress": 1
174+
}
175+
```
168176

169177
If the rescan wasn't able to complete fully (`lnd` was shutdown for example),
170178
then from `lncli unlock`, it's possible to _restart_ the rescan from where it

lnrpc/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ description):
5555
* Lists all available connected peers.
5656
* GetInfo
5757
* Returns basic data concerning the daemon.
58+
* GetRecoveryInfo
59+
* Returns information about recovery process.
5860
* PendingChannels
5961
* List the number of pending (not fully confirmed) channels.
6062
* ListChannels

lnrpc/rest-annotations.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ http:
4141
get: "/v1/peers/subscribe"
4242
- selector: lnrpc.Lightning.GetInfo
4343
get: "/v1/getinfo"
44+
- selector: lnrpc.Lightning.GetRecoveryInfo
45+
get: "/v1/getrecoveryinfo"
4446
- selector: lnrpc.Lightning.PendingChannels
4547
get: "/v1/channels/pending"
4648
- selector: lnrpc.Lightning.ListChannels

lnrpc/routerrpc/router.pb.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lnrpc/routerrpc/router.proto

+9-9
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,16 @@ service Router {
9898
rpc TrackPayment (TrackPaymentRequest) returns (stream PaymentStatus) {
9999
option deprecated = true;
100100
}
101-
101+
102102
/**
103103
HtlcInterceptor dispatches a bi-directional streaming RPC in which
104104
Forwarded HTLC requests are sent to the client and the client responds with
105105
a boolean that tells LND if this htlc should be intercepted.
106106
In case of interception, the htlc can be either settled, cancelled or
107107
resumed later by using the ResolveHoldForward endpoint.
108108
*/
109-
rpc HtlcInterceptor (stream ForwardHtlcInterceptResponse) returns (stream ForwardHtlcInterceptRequest);
109+
rpc HtlcInterceptor (stream ForwardHtlcInterceptResponse)
110+
returns (stream ForwardHtlcInterceptRequest);
110111
}
111112

112113
message SendPaymentRequest {
@@ -589,7 +590,7 @@ message PaymentStatus {
589590
repeated lnrpc.HTLCAttempt htlcs = 4;
590591
}
591592

592-
message CircuitKey {
593+
message CircuitKey {
593594
/// The id of the channel that the is part of this circuit.
594595
uint64 chan_id = 1;
595596

@@ -618,14 +619,14 @@ message ForwardHtlcInterceptRequest {
618619
}
619620

620621
/**
621-
ForwardHtlcInterceptResponse enables the caller to resolve a previously hold forward.
622-
The caller can choose either to:
622+
ForwardHtlcInterceptResponse enables the caller to resolve a previously hold
623+
forward. The caller can choose either to:
623624
- `Resume`: Execute the default behavior (usually forward).
624625
- `Reject`: Fail the htlc backwards.
625626
- `Settle`: Settle this htlc with a given preimage.
626627
*/
627628
message ForwardHtlcInterceptResponse {
628-
/**
629+
/**
629630
The key of this forwarded htlc. It defines the incoming channel id and
630631
the index in this channel.
631632
*/
@@ -638,9 +639,8 @@ message ForwardHtlcInterceptResponse {
638639
bytes preimage = 3;
639640
}
640641

641-
enum ResolveHoldForwardAction {
642+
enum ResolveHoldForwardAction {
642643
SETTLE = 0;
643644
FAIL = 1;
644-
RESUME = 2;
645+
RESUME = 2;
645646
}
646-

0 commit comments

Comments
 (0)