ekzyis 5b2e835722 Separate client and server imports by files
* 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
2024-07-16 15:46:44 +02:00

45 lines
1000 B
JavaScript

import { ensureB64 } from '@/lib/format'
import { createInvoice as clnCreateInvoice } from '@/lib/cln'
import { addWalletLog } from '@/api/resolvers/wallet'
export * from 'wallets/cln'
export const walletType = 'CLN'
export const walletField = 'walletCLN'
export const testConnect = async (
{ socket, rune, cert },
{ me, models }
) => {
cert = ensureB64(cert)
const inv = await clnCreateInvoice({
socket,
rune,
cert,
description: 'SN connection test',
msats: 'any',
expiry: 0
})
await addWalletLog({ wallet: { type: 'CLN' }, level: 'SUCCESS', message: 'connected to CLN' }, { me, models })
return inv
}
export const createInvoice = async (
{ amount },
{ socket, rune, cert },
{ me, models, lnd }
) => {
cert = ensureB64(cert)
const inv = await clnCreateInvoice({
socket,
rune,
cert,
description: me.hideInvoiceDesc ? undefined : 'autowithdraw to CLN from SN',
msats: amount + 'sat',
expiry: 360
})
return inv.bolt11
}