Update LNC code
* remove LNC FIXMEs Mhh, I guess the TURN server was down or something? It now magically works. Or maybe it only works once per mnemonic? * also removed the lnc.lnd.lightning.getInfo() call since we don't ask and need permission for this RPC for payments. * setting a password does not work though. It fails with 'The password provided is not valid' which is triggered at https://github.com/lightninglabs/lnc-web/blob/main/lib/util/credentialStore.ts#L81.
This commit is contained in:
parent
9af8e63355
commit
920478a72c
|
@ -13,7 +13,8 @@ import * as lnAddr from '@/components/wallet/lightning-address'
|
|||
import * as cln from '@/components/wallet/cln'
|
||||
import { gql, useApolloClient, useQuery } from '@apollo/client'
|
||||
import { REMOVE_WALLET, WALLET_BY_TYPE } from '@/fragments/wallet'
|
||||
import { autowithdrawInitial } from '../autowithdraw-shared'
|
||||
import { autowithdrawInitial } from '@/components/autowithdraw-shared'
|
||||
import { useShowModal } from '@/components/modal'
|
||||
|
||||
// wallet definitions
|
||||
export const WALLET_DEFS = [lnbits, nwc, lnc, lnd, lnAddr, cln]
|
||||
|
@ -27,6 +28,7 @@ export const Status = {
|
|||
|
||||
export function useWallet (name) {
|
||||
const me = useMe()
|
||||
const showModal = useShowModal()
|
||||
|
||||
const wallet = name ? getWalletByName(name) : getEnabledWallet(me)
|
||||
const { logger, deleteLogs } = useWalletLogger(wallet)
|
||||
|
@ -42,14 +44,14 @@ export function useWallet (name) {
|
|||
const hash = bolt11Tags(bolt11).payment_hash
|
||||
logger.info('sending payment:', `payment_hash=${hash}`)
|
||||
try {
|
||||
const { preimage } = await wallet.sendPayment(bolt11, config, { logger })
|
||||
const { preimage } = await wallet.sendPayment(bolt11, config, { me, logger, status, showModal })
|
||||
logger.ok('payment successful:', `payment_hash=${hash}`, `preimage=${preimage}`)
|
||||
} catch (err) {
|
||||
const message = err.message || err.toString?.()
|
||||
logger.error('payment failed:', `payment_hash=${hash}`, message)
|
||||
throw err
|
||||
}
|
||||
}, [wallet, config, logger])
|
||||
}, [me, wallet, config, logger, status])
|
||||
|
||||
const enable = useCallback(() => {
|
||||
enableWallet(name, me)
|
||||
|
|
|
@ -38,22 +38,14 @@ export async function validate ({ pairingPhrase, password }, { me, logger }) {
|
|||
try {
|
||||
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()
|
||||
logger.ok('connected')
|
||||
logger.info('validating permissions ...')
|
||||
await validateNarrowPerms(lnc)
|
||||
logger.ok('permissions ok')
|
||||
lnc.credentials.password = password || XXX_DEFAULT_PASSWORD
|
||||
logger.info('getting lightning info ...')
|
||||
await lnc.lightning.getInfo()
|
||||
logger.ok('info received')
|
||||
} finally {
|
||||
// FIXME: this fails with this error:
|
||||
// Cannot read properties of undefined (reading 'wasmClientDisconnect')
|
||||
// uncommented because it shadows the error from lnc.connect()
|
||||
// lnc.disconnect()
|
||||
lnc.disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,11 +69,11 @@ async function unlock ({ password }, { lnc, status, showModal, logger }) {
|
|||
onSubmit={async (values) => {
|
||||
try {
|
||||
lnc.credentials.password = values?.password
|
||||
logger.ok('wallet enabled')
|
||||
logger.ok('wallet unlocked')
|
||||
onClose()
|
||||
resolve(values.password)
|
||||
} catch (err) {
|
||||
logger.error('failed attempt to unlock wallet', err)
|
||||
logger.error('failed to unlock wallet:', err)
|
||||
throw err
|
||||
}
|
||||
}}
|
||||
|
|
Loading…
Reference in New Issue