Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
connect(options) {
if (this.grpc && this.grpc.state !== 'ready') {
throw new Error('Can not connect (already connected)')
}
this.options = options
// Create a new grpc instance using settings from init options.
const grpcOptions = this.getConnectionSettings()
this.grpc = new LndGrpc(grpcOptions)
// Set up service accessors.
this.services = this.grpc.services
// Inject helper methods.
Object.assign(this.services.Lightning, lightningMethods)
Object.assign(this.services.Lightning, lightningSubscriptions)
// Setup gRPC event handlers.
this.grpc.on('locked', () => {
this.emit(GRPC_WALLET_UNLOCKER_SERVICE_ACTIVE)
})
this.grpc.on('active', () => {
this.emit(GRPC_LIGHTNING_SERVICE_ACTIVE)
this.subscribeAll()
})