Add FIXMEs for LNC
I can't get LNC to connect. It just hangs forever on lnc.connect(). See FIXMEs.
This commit is contained in:
parent
eda7fd6b46
commit
dae69ec4b3
|
@ -54,7 +54,7 @@ export function useWallet (name) {
|
||||||
try {
|
try {
|
||||||
// validate should log custom INFO and OK message
|
// validate should log custom INFO and OK message
|
||||||
// TODO: add timeout
|
// TODO: add timeout
|
||||||
await wallet.validate({ logger, ...config })
|
await wallet.validate({ me, logger, ...config })
|
||||||
saveConfig(config)
|
saveConfig(config)
|
||||||
logger.ok('wallet attached')
|
logger.ok('wallet attached')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -62,7 +62,7 @@ export function useWallet (name) {
|
||||||
logger.error(message)
|
logger.error(message)
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}, [saveConfig, logger])
|
}, [saveConfig, me, logger])
|
||||||
|
|
||||||
// delete is a reserved keyword
|
// delete is a reserved keyword
|
||||||
const delete_ = useCallback(() => {
|
const delete_ = useCallback(() => {
|
||||||
|
|
|
@ -38,11 +38,23 @@ export async function validate ({ me, logger, pairingPhrase, password }) {
|
||||||
const lnc = await getLNC({ me })
|
const lnc = await getLNC({ me })
|
||||||
try {
|
try {
|
||||||
lnc.credentials.pairingPhrase = pairingPhrase
|
lnc.credentials.pairingPhrase = pairingPhrase
|
||||||
|
logger.info('connecting ...')
|
||||||
|
// FIXME: this fails with this error:
|
||||||
|
// Cannot assign to read only property 'undefined' of object '#<Window>'
|
||||||
await lnc.connect()
|
await lnc.connect()
|
||||||
|
logger.ok('connected')
|
||||||
|
logger.info('validating permissions ...')
|
||||||
await validateNarrowPerms(lnc)
|
await validateNarrowPerms(lnc)
|
||||||
|
logger.ok('permissions ok')
|
||||||
lnc.credentials.password = password || XXX_DEFAULT_PASSWORD
|
lnc.credentials.password = password || XXX_DEFAULT_PASSWORD
|
||||||
|
logger.info('getting lightning info ...')
|
||||||
|
await lnc.lightning.getInfo()
|
||||||
|
logger.ok('info received')
|
||||||
} finally {
|
} finally {
|
||||||
lnc.disconnect()
|
// FIXME: this fails with this error:
|
||||||
|
// Cannot read properties of undefined (reading 'wasmClientDisconnect')
|
||||||
|
// uncommented because it shadows the error from lnc.connect()
|
||||||
|
// lnc.disconnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +75,7 @@ export const schema = object({
|
||||||
|
|
||||||
const mutex = new Mutex()
|
const mutex = new Mutex()
|
||||||
|
|
||||||
export async function unlock ({ lnc, password, status, showModal, logger }) {
|
async function unlock ({ lnc, password, status, showModal, logger }) {
|
||||||
if (status === Status.Enabled) return password
|
if (status === Status.Enabled) return password
|
||||||
|
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
|
@ -104,14 +116,16 @@ export async function unlock ({ lnc, password, status, showModal, logger }) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function sendPayment ({ bolt11, pairingPhrase, password: configuredPassword, logger }) {
|
// FIXME: pass me, status, showModal in useWallet hook
|
||||||
|
export async function sendPayment ({ bolt11, pairingPhrase, password: configuredPassword, me, status, showModal, logger }) {
|
||||||
const hash = bolt11Tags(bolt11).payment_hash
|
const hash = bolt11Tags(bolt11).payment_hash
|
||||||
|
|
||||||
return await mutex.runExclusive(async () => {
|
return await mutex.runExclusive(async () => {
|
||||||
let lnc
|
let lnc
|
||||||
try {
|
try {
|
||||||
lnc = await getLNC()
|
lnc = await getLNC({ me })
|
||||||
const password = await unlock({ lnc, password: configuredPassword })
|
// TODO: pass status, showModal to unlock
|
||||||
|
const password = await unlock({ lnc, password: configuredPassword, status, showModal, logger })
|
||||||
// credentials need to be decrypted before connecting after a disconnect
|
// credentials need to be decrypted before connecting after a disconnect
|
||||||
lnc.credentials.password = password || XXX_DEFAULT_PASSWORD
|
lnc.credentials.password = password || XXX_DEFAULT_PASSWORD
|
||||||
await lnc.connect()
|
await lnc.connect()
|
||||||
|
@ -164,7 +178,7 @@ function getLNC ({ me }) {
|
||||||
return window.lnc
|
return window.lnc
|
||||||
}
|
}
|
||||||
|
|
||||||
async function validateNarrowPerms (lnc) {
|
function validateNarrowPerms (lnc) {
|
||||||
if (!lnc.hasPerms('lnrpc.Lightning.SendPaymentSync')) {
|
if (!lnc.hasPerms('lnrpc.Lightning.SendPaymentSync')) {
|
||||||
throw new Error('missing permission: lnrpc.Lightning.SendPaymentSync')
|
throw new Error('missing permission: lnrpc.Lightning.SendPaymentSync')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue