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({
|
export const lncSchema = object({
|
||||||
pairingPhrase: array()
|
pairingPhrase: string()
|
||||||
.transform(function (value, originalValue) {
|
.test(async (value, context) => {
|
||||||
if (this.isType(value) && value !== null) {
|
const words = value ? value.trim().split(/[\s]+/) : []
|
||||||
return value
|
|
||||||
}
|
|
||||||
return originalValue ? originalValue.trim().split(/[\s]+/) : []
|
|
||||||
})
|
|
||||||
.test(async (words, context) => {
|
|
||||||
for (const w of words) {
|
for (const w of words) {
|
||||||
try {
|
try {
|
||||||
await string().oneOf(bip39Words).validate(w)
|
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` })
|
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
|
return true
|
||||||
})
|
})
|
||||||
.min(2, 'needs at least two words')
|
|
||||||
.max(10, 'max 10 words')
|
|
||||||
.required('required')
|
.required('required')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
16
package-lock.json
generated
16
package-lock.json
generated
@ -13,7 +13,7 @@
|
|||||||
"@as-integrations/next": "^2.0.2",
|
"@as-integrations/next": "^2.0.2",
|
||||||
"@auth/prisma-adapter": "^1.0.3",
|
"@auth/prisma-adapter": "^1.0.3",
|
||||||
"@graphql-tools/schema": "^10.0.0",
|
"@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",
|
"@noble/curves": "^1.2.0",
|
||||||
"@opensearch-project/opensearch": "^2.4.0",
|
"@opensearch-project/opensearch": "^2.4.0",
|
||||||
"@prisma/client": "^5.17.0",
|
"@prisma/client": "^5.17.0",
|
||||||
@ -3819,16 +3819,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@lightninglabs/lnc-core": {
|
"node_modules/@lightninglabs/lnc-core": {
|
||||||
"version": "0.3.1-alpha",
|
"version": "0.3.2-alpha",
|
||||||
"resolved": "https://registry.npmjs.org/@lightninglabs/lnc-core/-/lnc-core-0.3.1-alpha.tgz",
|
"resolved": "https://registry.npmjs.org/@lightninglabs/lnc-core/-/lnc-core-0.3.2-alpha.tgz",
|
||||||
"integrity": "sha512-I/hThdItLWJ6RU8Z27ZIXhpBS2JJuD3+TjtaQXX2CabaUYXlcN4sk+Kx8N/zG/fk8qZvjlRWum4vHu4ZX554Fg=="
|
"integrity": "sha512-H6tG+X9txCIdxTR+GPsbImzP2Juo+6Uvq/Ipaijd7xPISzgEU4J4GNE5PEHuIZqbnBo1RmpuXnFG6dmsl3PTzQ=="
|
||||||
},
|
},
|
||||||
"node_modules/@lightninglabs/lnc-web": {
|
"node_modules/@lightninglabs/lnc-web": {
|
||||||
"version": "0.3.1-alpha",
|
"version": "0.3.2-alpha",
|
||||||
"resolved": "https://registry.npmjs.org/@lightninglabs/lnc-web/-/lnc-web-0.3.1-alpha.tgz",
|
"resolved": "https://registry.npmjs.org/@lightninglabs/lnc-web/-/lnc-web-0.3.2-alpha.tgz",
|
||||||
"integrity": "sha512-yL5SgBkl6kd6ISzJHGlSN7TXbiDoo1pfGvTOIdVWYVyXtEeW8PT+x6YGOmyQXGFT2OOf7fC7PfP9VnskDPuFaA==",
|
"integrity": "sha512-3aCBugBf0NzczpJqmHn03Oq2Ju9W5n0+nOdAe+Y/Zhf6YLXdqG1PTJ2J+7TXncpiogfPYDCw95tVQqSi4Zi/ZA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lightninglabs/lnc-core": "0.3.1-alpha",
|
"@lightninglabs/lnc-core": "0.3.2-alpha",
|
||||||
"crypto-js": "4.2.0"
|
"crypto-js": "4.2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"@as-integrations/next": "^2.0.2",
|
"@as-integrations/next": "^2.0.2",
|
||||||
"@auth/prisma-adapter": "^1.0.3",
|
"@auth/prisma-adapter": "^1.0.3",
|
||||||
"@graphql-tools/schema": "^10.0.0",
|
"@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",
|
"@noble/curves": "^1.2.0",
|
||||||
"@opensearch-project/opensearch": "^2.4.0",
|
"@opensearch-project/opensearch": "^2.4.0",
|
||||||
"@prisma/client": "^5.17.0",
|
"@prisma/client": "^5.17.0",
|
||||||
|
@ -24,6 +24,7 @@ async function disconnect (lnc, logger) {
|
|||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
}, 50)
|
}, 50)
|
||||||
|
logger.info('disconnected')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('failed to disconnect from lnc', err)
|
logger.error('failed to disconnect from lnc', err)
|
||||||
}
|
}
|
||||||
@ -83,10 +84,25 @@ export async function sendPayment (bolt11, credentials, { logger }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getLNC (credentials = {}) {
|
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')
|
const { default: { default: LNC } } = await import('@lightninglabs/lnc-web')
|
||||||
return new LNC({
|
window.lnc = new LNC({
|
||||||
credentialStore: new LncCredentialStore({ ...credentials, serverHost: 'mailbox.terminal.lightning.today:443' })
|
credentialStore: new LncCredentialStore({
|
||||||
|
...credentials,
|
||||||
|
serverHost
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
return window.lnc
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateNarrowPerms (lnc) {
|
function validateNarrowPerms (lnc) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user