Skip to content

Commit 15ec140

Browse files
committed
feat(initservice): return list of wallets
This adds the list of lnd clients that were initialized or unlocked by an `InitNode` or `CreateNode` call to their respective responses. This can be used to display potentially helpful information to the user. Closes #1018.
1 parent 260a73b commit 15ec140

File tree

8 files changed

+251
-20
lines changed

8 files changed

+251
-20
lines changed

docs/api.md

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

lib/grpc/GrpcInitService.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ class GrpcInitService {
3434
*/
3535
public createNode: grpc.handleUnaryCall<xudrpc.CreateNodeRequest, xudrpc.CreateNodeResponse> = async (call, callback) => {
3636
try {
37-
const mnemonic = await this.initService.createNode(call.request.toObject());
37+
const { mnemonic, initializedLndWallets } = await this.initService.createNode(call.request.toObject());
3838
const response = new xudrpc.CreateNodeResponse();
3939
if (mnemonic) {
4040
response.setSeedMnemonicList(mnemonic);
4141
}
42+
if (initializedLndWallets) {
43+
response.setInitializedLndsList(initializedLndWallets);
44+
}
4245

4346
callback(null, response);
4447
} catch (err) {
@@ -52,8 +55,9 @@ class GrpcInitService {
5255
*/
5356
public unlockNode: grpc.handleUnaryCall<xudrpc.UnlockNodeRequest, xudrpc.UnlockNodeResponse> = async (call, callback) => {
5457
try {
55-
await this.initService.unlockNode(call.request.toObject());
58+
const unlockedLndClients = await this.initService.unlockNode(call.request.toObject());
5659
const response = new xudrpc.UnlockNodeResponse();
60+
response.setUnlockedLndsList(unlockedLndClients);
5761

5862
callback(null, response);
5963
} catch (err) {

lib/proto/xudrpc.swagger.json

Lines changed: 27 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/proto/xudrpc_pb.d.ts

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

lib/proto/xudrpc_pb.js

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

lib/service/InitService.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class InitService extends EventEmitter {
2828

2929
this.pendingCall = true;
3030
const seed = await this.swapClientManager.genSeed();
31+
let initializedLndWallets: string[] | undefined;
3132
let nodeKey: NodeKey;
3233

3334
if (seed) {
@@ -43,15 +44,18 @@ class InitService extends EventEmitter {
4344
nodeKey = new NodeKey(privKey);
4445

4546
// use this seed to init any lnd wallets that are uninitialized
46-
await this.swapClientManager.initWallets(password, seed.cipherSeedMnemonicList);
47+
initializedLndWallets = await this.swapClientManager.initWallets(password, seed.cipherSeedMnemonicList);
4748
} else {
4849
// we couldn't generate a seed externally, so we must create one locally
4950
nodeKey = await NodeKey.generate();
5051
}
5152

5253
await nodeKey.toFile(this.nodeKeyPath, password);
5354
this.emit('nodekey', nodeKey);
54-
return seed ? seed.cipherSeedMnemonicList : undefined;
55+
return {
56+
initializedLndWallets,
57+
mnemonic: seed ? seed.cipherSeedMnemonicList : undefined,
58+
};
5559
}
5660

5761
public unlockNode = async (args: { password: string }) => {
@@ -68,7 +72,7 @@ class InitService extends EventEmitter {
6872
const nodeKey = await NodeKey.fromFile(this.nodeKeyPath, password);
6973
this.emit('nodekey', nodeKey);
7074

71-
await this.swapClientManager.unlockWallets(password);
75+
return this.swapClientManager.unlockWallets(password);
7276
}
7377
}
7478

0 commit comments

Comments
 (0)