Followed the "complete example" given in the README, working fine with the admin macaroon but can't get just await Lightning.addInvoice({ value: 1 }); to work with a invoice macaroon.
Tried it with & without connect() beforehand, tried it with & without activateLightning() beforehand.
Using without those gets a
UnhandledPromiseRejectionWarning: TypeError: Lightning.addInvoice is not a function
at test (/Users/anthony/Dev/Repos/test/test.js:45:42)
at Object.<anonymous> (/Users/anthony/Dev/Repos/test/test.js:53:1)
at Module._compile (internal/modules/cjs/loader.js:1121:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
at Module.load (internal/modules/cjs/loader.js:976:32)
at Function.Module._load (internal/modules/cjs/loader.js:884:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:67:12)
at internal/main/run_main_module.js:17:47
Using with them gets a
(node:19196) UnhandledPromiseRejectionWarning: Error: permission denied
at Http2CallStream.<anonymous> (/Users/anthony/Dev/Repos/test/node_modules/@grpc/grpc-js/build/src/client.js:96:45)
at Http2CallStream.emit (events.js:215:7)
at /Users/anthony/Dev/Repos/test/node_modules/@grpc/grpc-js/build/src/call-stream.js:71:22
at processTicksAndRejections (internal/process/task_queues.js:75:11)
Complete test for double checking:
const LndGrpc = require('lnd-grpc');
const adminMacaroon = '...';
const invoiceMacaroon = '...';
const hostUrl = '...';
async function test() {
const grpc = new LndGrpc({
host: hostUrl,
cert: null,
macaroon: invoiceMacaroon,
});
// Establish a connection.
console.log('about to connect')
// await grpc.connect()
console.log('connected')
// Do something cool if we detect that the wallet is locked.
grpc.on(`locked`, () => console.log('wallet locked!'))
// Do something cool when the wallet gets unlocked.
grpc.on(`active`, () => console.log('wallet unlocked!'))
// Do something cool when the connection gets disconnected.
grpc.on(`disconnected`, () => console.log('disconnected from lnd!'))
// Check if the wallet is locked and unlock if needed.
if (grpc.state === 'locked') {
const {WalletUnlocker} = grpc.services
await WalletUnlocker.unlockWallet({
wallet_password: Buffer.from('mypassword'),
})
// After unlocking the wallet, activate the Lightning service and all of it's subservices.
await WalletUnlocker.activateLightning()
}
// Make some api calls...
await grpc.activateLightning();
const {Lightning, Autopilot, Invoices} = grpc.services
console.log('about to create invoice..');
const invoiceTest2 = await Lightning.addInvoice({ value: 1 });
console.log(invoiceTest2);
// Disconnect from all services.
await grpc.disconnect()
}
test();
I believe even things like getInfo is blocked by LND with the invoice-only macaroon. Seems as though this library relies on checking specific things like whether or not the wallet is locked?
Could an invoiceOnly flag be passed in to allow certain things like Lightning.addInvoice to go through without needing connect or activateLightning? Just some ideas.
Followed the "complete example" given in the README, working fine with the admin macaroon but can't get just
await Lightning.addInvoice({ value: 1 });
to work with a invoice macaroon.Tried it with & without
connect()
beforehand, tried it with & withoutactivateLightning()
beforehand.Using without those gets a
Using with them gets a
Complete test for double checking:
I believe even things like
getInfo
is blocked by LND with the invoice-only macaroon. Seems as though this library relies on checking specific things like whether or not the wallet is locked?Could an
invoiceOnly
flag be passed in to allow certain things likeLightning.addInvoice
to go through without needingconnect
oractivateLightning
? Just some ideas.