* wallets now consist of an index.js, a client.js and a server.js file * client.js is imported on the client and contains the client portion * server.js is imported on the server and contains the server porition * both reexport index.js so everything in index.js can be shared by client and server * every wallet contains a client.js file since they are all imported on the client to show the cards * client.js of every wallet is reexported as an array in wallets/client.js * server.js of every wallet is reexported as an array in wallets/server.js FIXME: for some reason, worker does not properly import the default export of wallets/server.js
33 lines
817 B
JavaScript
33 lines
817 B
JavaScript
import { fetchLnAddrInvoice } from '@/api/resolvers/wallet'
|
|
import { lnAddrOptions } from '@/lib/lnurl'
|
|
|
|
export * from 'wallets/lightning-address'
|
|
|
|
export const walletType = 'LIGHTNING_ADDRESS'
|
|
|
|
export const walletField = 'walletLightningAddress'
|
|
|
|
export const testConnect = async (
|
|
{ address },
|
|
{ me, models, addWalletLog }
|
|
) => {
|
|
const options = await lnAddrOptions(address)
|
|
await addWalletLog({ wallet: { type: 'LIGHTNING_ADDRESS' }, level: 'SUCCESS', message: 'fetched payment details' }, { me, models })
|
|
return options
|
|
}
|
|
|
|
export const createInvoice = async (
|
|
{ amount, maxFee },
|
|
{ address },
|
|
{ me, models, lnd, lnService }
|
|
) => {
|
|
const res = await fetchLnAddrInvoice({ addr: address, amount, maxFee }, {
|
|
me,
|
|
models,
|
|
lnd,
|
|
lnService,
|
|
autoWithdraw: true
|
|
})
|
|
return res.pr
|
|
}
|