Skip to content

Commit a8e46f5

Browse files
committed
lnc-web: expose wasmClientGetExpiry(), wasmClientHasPerms(), wasmClientIsReadOnly(), and wasmClientStatus()
1 parent e9508aa commit a8e46f5

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

lib/lnc.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,38 @@ export default class LNC {
7878
);
7979
}
8080

81+
get status() {
82+
return (
83+
this.wasm &&
84+
this.wasm.wasmClientStatus &&
85+
this.wasm.wasmClientStatus()
86+
);
87+
}
88+
89+
get expiry(): Date {
90+
return (
91+
this.wasm &&
92+
this.wasm.wasmClientGetExpiry &&
93+
new Date(this.wasm.wasmClientGetExpiry() * 1000)
94+
);
95+
}
96+
97+
get isReadOnly() {
98+
return (
99+
this.wasm &&
100+
this.wasm.wasmClientIsReadOnly &&
101+
this.wasm.wasmClientIsReadOnly()
102+
);
103+
}
104+
105+
hasPerms(permission: string) {
106+
return (
107+
this.wasm &&
108+
this.wasm.wasmClientHasPerms &&
109+
this.wasm.wasmClientHasPerms(permission)
110+
);
111+
}
112+
81113
/**
82114
* Downloads the WASM client binary
83115
*/

lib/types/lnc.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ export interface WasmGlobal {
3131
request: any,
3232
callback: (response: string) => any
3333
) => void;
34+
/**
35+
* Returns true if client has specific permissions
36+
* e.g. 'lnrpc.Lightning.GetInfo'
37+
*/
38+
wasmClientHasPerms: (permission: string) => boolean;
39+
/**
40+
* Returns true if the WASM client is read only
41+
*/
42+
wasmClientIsReadOnly: () => boolean;
43+
/**
44+
* Returns the WASM client status
45+
*/
46+
wasmClientStatus: () => string;
47+
/**
48+
* Returns the WASM client expiry time
49+
*/
50+
wasmClientGetExpiry: () => number;
3451
}
3552

3653
export interface LncConfig {

0 commit comments

Comments
 (0)