fix lnc by always reusing the same lnc object
This commit is contained in:
parent
c0de29cb82
commit
467a9d6a76
|
@ -741,14 +741,9 @@ export const blinkSchema = object({
|
|||
})
|
||||
|
||||
export const lncSchema = object({
|
||||
pairingPhrase: array()
|
||||
.transform(function (value, originalValue) {
|
||||
if (this.isType(value) && value !== null) {
|
||||
return value
|
||||
}
|
||||
return originalValue ? originalValue.trim().split(/[\s]+/) : []
|
||||
})
|
||||
.test(async (words, context) => {
|
||||
pairingPhrase: string()
|
||||
.test(async (value, context) => {
|
||||
const words = value ? value.trim().split(/[\s]+/) : []
|
||||
for (const w of words) {
|
||||
try {
|
||||
await string().oneOf(bip39Words).validate(w)
|
||||
|
@ -756,10 +751,14 @@ export const lncSchema = object({
|
|||
return context.createError({ message: `'${w}' is not a valid pairing phrase word` })
|
||||
}
|
||||
}
|
||||
if (words.length < 2) {
|
||||
return context.createError({ message: 'needs at least two words' })
|
||||
}
|
||||
if (words.length > 10) {
|
||||
return context.createError({ message: 'max 10 words' })
|
||||
}
|
||||
return true
|
||||
})
|
||||
.min(2, 'needs at least two words')
|
||||
.max(10, 'max 10 words')
|
||||
.required('required')
|
||||
})
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"@as-integrations/next": "^2.0.2",
|
||||
"@auth/prisma-adapter": "^1.0.3",
|
||||
"@graphql-tools/schema": "^10.0.0",
|
||||
"@lightninglabs/lnc-web": "^0.3.1-alpha",
|
||||
"@lightninglabs/lnc-web": "^0.3.2-alpha",
|
||||
"@noble/curves": "^1.2.0",
|
||||
"@opensearch-project/opensearch": "^2.4.0",
|
||||
"@prisma/client": "^5.17.0",
|
||||
|
@ -3819,16 +3819,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@lightninglabs/lnc-core": {
|
||||
"version": "0.3.1-alpha",
|
||||
"resolved": "https://registry.npmjs.org/@lightninglabs/lnc-core/-/lnc-core-0.3.1-alpha.tgz",
|
||||
"integrity": "sha512-I/hThdItLWJ6RU8Z27ZIXhpBS2JJuD3+TjtaQXX2CabaUYXlcN4sk+Kx8N/zG/fk8qZvjlRWum4vHu4ZX554Fg=="
|
||||
"version": "0.3.2-alpha",
|
||||
"resolved": "https://registry.npmjs.org/@lightninglabs/lnc-core/-/lnc-core-0.3.2-alpha.tgz",
|
||||
"integrity": "sha512-H6tG+X9txCIdxTR+GPsbImzP2Juo+6Uvq/Ipaijd7xPISzgEU4J4GNE5PEHuIZqbnBo1RmpuXnFG6dmsl3PTzQ=="
|
||||
},
|
||||
"node_modules/@lightninglabs/lnc-web": {
|
||||
"version": "0.3.1-alpha",
|
||||
"resolved": "https://registry.npmjs.org/@lightninglabs/lnc-web/-/lnc-web-0.3.1-alpha.tgz",
|
||||
"integrity": "sha512-yL5SgBkl6kd6ISzJHGlSN7TXbiDoo1pfGvTOIdVWYVyXtEeW8PT+x6YGOmyQXGFT2OOf7fC7PfP9VnskDPuFaA==",
|
||||
"version": "0.3.2-alpha",
|
||||
"resolved": "https://registry.npmjs.org/@lightninglabs/lnc-web/-/lnc-web-0.3.2-alpha.tgz",
|
||||
"integrity": "sha512-3aCBugBf0NzczpJqmHn03Oq2Ju9W5n0+nOdAe+Y/Zhf6YLXdqG1PTJ2J+7TXncpiogfPYDCw95tVQqSi4Zi/ZA==",
|
||||
"dependencies": {
|
||||
"@lightninglabs/lnc-core": "0.3.1-alpha",
|
||||
"@lightninglabs/lnc-core": "0.3.2-alpha",
|
||||
"crypto-js": "4.2.0"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"@as-integrations/next": "^2.0.2",
|
||||
"@auth/prisma-adapter": "^1.0.3",
|
||||
"@graphql-tools/schema": "^10.0.0",
|
||||
"@lightninglabs/lnc-web": "^0.3.1-alpha",
|
||||
"@lightninglabs/lnc-web": "^0.3.2-alpha",
|
||||
"@noble/curves": "^1.2.0",
|
||||
"@opensearch-project/opensearch": "^2.4.0",
|
||||
"@prisma/client": "^5.17.0",
|
||||
|
|
|
@ -24,6 +24,7 @@ async function disconnect (lnc, logger) {
|
|||
resolve()
|
||||
})
|
||||
}, 50)
|
||||
logger.info('disconnected')
|
||||
} catch (err) {
|
||||
logger.error('failed to disconnect from lnc', err)
|
||||
}
|
||||
|
@ -83,10 +84,25 @@ export async function sendPayment (bolt11, credentials, { logger }) {
|
|||
}
|
||||
|
||||
async function getLNC (credentials = {}) {
|
||||
const serverHost = 'mailbox.terminal.lightning.today:443'
|
||||
// XXX we MUST reuse the same instance of LNC because it references a global Go object
|
||||
// that holds closures to the first LNC instance it's created with
|
||||
if (window.lnc) {
|
||||
window.lnc.credentials.credentials = {
|
||||
...window.lnc.credentials.credentials,
|
||||
...credentials,
|
||||
serverHost
|
||||
}
|
||||
return window.lnc
|
||||
}
|
||||
const { default: { default: LNC } } = await import('@lightninglabs/lnc-web')
|
||||
return new LNC({
|
||||
credentialStore: new LncCredentialStore({ ...credentials, serverHost: 'mailbox.terminal.lightning.today:443' })
|
||||
window.lnc = new LNC({
|
||||
credentialStore: new LncCredentialStore({
|
||||
...credentials,
|
||||
serverHost
|
||||
})
|
||||
})
|
||||
return window.lnc
|
||||
}
|
||||
|
||||
function validateNarrowPerms (lnc) {
|
||||
|
|
Loading…
Reference in New Issue