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 * as cln from '@/components/wallet/cln'
 | 
				
			||||||
import { gql, useApolloClient, useQuery } from '@apollo/client'
 | 
					import { gql, useApolloClient, useQuery } from '@apollo/client'
 | 
				
			||||||
import { REMOVE_WALLET, WALLET_BY_TYPE } from '@/fragments/wallet'
 | 
					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
 | 
					// wallet definitions
 | 
				
			||||||
export const WALLET_DEFS = [lnbits, nwc, lnc, lnd, lnAddr, cln]
 | 
					export const WALLET_DEFS = [lnbits, nwc, lnc, lnd, lnAddr, cln]
 | 
				
			||||||
@ -27,6 +28,7 @@ export const Status = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export function useWallet (name) {
 | 
					export function useWallet (name) {
 | 
				
			||||||
  const me = useMe()
 | 
					  const me = useMe()
 | 
				
			||||||
 | 
					  const showModal = useShowModal()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const wallet = name ? getWalletByName(name) : getEnabledWallet(me)
 | 
					  const wallet = name ? getWalletByName(name) : getEnabledWallet(me)
 | 
				
			||||||
  const { logger, deleteLogs } = useWalletLogger(wallet)
 | 
					  const { logger, deleteLogs } = useWalletLogger(wallet)
 | 
				
			||||||
@ -42,14 +44,14 @@ export function useWallet (name) {
 | 
				
			|||||||
    const hash = bolt11Tags(bolt11).payment_hash
 | 
					    const hash = bolt11Tags(bolt11).payment_hash
 | 
				
			||||||
    logger.info('sending payment:', `payment_hash=${hash}`)
 | 
					    logger.info('sending payment:', `payment_hash=${hash}`)
 | 
				
			||||||
    try {
 | 
					    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}`)
 | 
					      logger.ok('payment successful:', `payment_hash=${hash}`, `preimage=${preimage}`)
 | 
				
			||||||
    } catch (err) {
 | 
					    } catch (err) {
 | 
				
			||||||
      const message = err.message || err.toString?.()
 | 
					      const message = err.message || err.toString?.()
 | 
				
			||||||
      logger.error('payment failed:', `payment_hash=${hash}`, message)
 | 
					      logger.error('payment failed:', `payment_hash=${hash}`, message)
 | 
				
			||||||
      throw err
 | 
					      throw err
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }, [wallet, config, logger])
 | 
					  }, [me, wallet, config, logger, status])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const enable = useCallback(() => {
 | 
					  const enable = useCallback(() => {
 | 
				
			||||||
    enableWallet(name, me)
 | 
					    enableWallet(name, me)
 | 
				
			||||||
 | 
				
			|||||||
@ -38,22 +38,14 @@ export async function validate ({ pairingPhrase, password }, { me, logger }) {
 | 
				
			|||||||
  try {
 | 
					  try {
 | 
				
			||||||
    lnc.credentials.pairingPhrase = pairingPhrase
 | 
					    lnc.credentials.pairingPhrase = pairingPhrase
 | 
				
			||||||
    logger.info('connecting ...')
 | 
					    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.ok('connected')
 | 
				
			||||||
    logger.info('validating permissions ...')
 | 
					    logger.info('validating permissions ...')
 | 
				
			||||||
    await validateNarrowPerms(lnc)
 | 
					    await validateNarrowPerms(lnc)
 | 
				
			||||||
    logger.ok('permissions ok')
 | 
					    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 {
 | 
				
			||||||
    // FIXME: this fails with this error:
 | 
					    lnc.disconnect()
 | 
				
			||||||
    //   Cannot read properties of undefined (reading 'wasmClientDisconnect')
 | 
					 | 
				
			||||||
    // uncommented because it shadows the error from lnc.connect()
 | 
					 | 
				
			||||||
    // lnc.disconnect()
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -77,11 +69,11 @@ async function unlock ({ password }, { lnc, status, showModal, logger }) {
 | 
				
			|||||||
          onSubmit={async (values) => {
 | 
					          onSubmit={async (values) => {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
              lnc.credentials.password = values?.password
 | 
					              lnc.credentials.password = values?.password
 | 
				
			||||||
              logger.ok('wallet enabled')
 | 
					              logger.ok('wallet unlocked')
 | 
				
			||||||
              onClose()
 | 
					              onClose()
 | 
				
			||||||
              resolve(values.password)
 | 
					              resolve(values.password)
 | 
				
			||||||
            } catch (err) {
 | 
					            } catch (err) {
 | 
				
			||||||
              logger.error('failed attempt to unlock wallet', err)
 | 
					              logger.error('failed to unlock wallet:', err)
 | 
				
			||||||
              throw err
 | 
					              throw err
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          }}
 | 
					          }}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user