Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Dec 18, 2024
1 parent bae01b3 commit 20c3e58
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions wallets/bolt12/server.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { withTimeout } from '@/lib/time'
import { fetchBolt12InvoiceFromOffer } from '@/lib/lndk'
import { isBolt12Invoice } from '@/lib/bolt12'
import { parseInvoice } from '@/lib/boltInvoices'
import { toPositiveNumber } from '@/lib/format'
export * from '@/wallets/bolt12'

export async function testCreateInvoice ({ offer }, { lnd }) {
const timeout = 15_000
return await withTimeout((async () => {
const invoice = await fetchBolt12InvoiceFromOffer({ lnd, offer, msats: 1000, description: 'test' })
if (!isBolt12Invoice(invoice)) throw new Error('not a bolt12 invoice')
const parsedInvoice = await parseInvoice({ lnd, request: invoice })
if (toPositiveNumber(parsedInvoice.mtokens) !== 1000) throw new Error('invalid invoice response')
return offer
})(), timeout)
const invoice = await fetchBolt12InvoiceFromOffer({ lnd, offer, msats: 1000, description: 'test' })
if (!isBolt12Invoice(invoice)) throw new Error('not a bolt12 invoice')
const parsedInvoice = await parseInvoice({ lnd, request: invoice })
if (toPositiveNumber(parsedInvoice.mtokens) !== 1000) throw new Error('invalid invoice response')
return offer
}

export async function createInvoice ({ msats, description, expiry }, { offer }, { lnd }) {
Expand Down

0 comments on commit 20c3e58

Please sign in to comment.