diff options
| author | Adam Soltys <[email protected]> | 2025-02-26 11:59:58 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-26 11:59:58 -0800 |
| commit | 1d541fd97210389f006e65d46ab783afbe82cea8 (patch) | |
| tree | 66781ea2992fa99198ed1e450cdb9b68acfbc4d9 /lib/invoices.ts | |
| parent | a14b987a392bc700975b048f37838da08e4ed255 (diff) | |
| download | coinos-server-1d541fd97210389f006e65d46ab783afbe82cea8.tar.gz coinos-server-1d541fd97210389f006e65d46ab783afbe82cea8.zip | |
payment types
Diffstat (limited to 'lib/invoices.ts')
| -rw-r--r-- | lib/invoices.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/invoices.ts b/lib/invoices.ts index 4710beb2..178f793a 100644 --- a/lib/invoices.ts +++ b/lib/invoices.ts @@ -2,12 +2,13 @@ import config from "$config"; import { db, g, s } from "$lib/db"; import { request } from "$lib/ecash"; import ln from "$lib/ln"; -import { types } from "$lib/payments"; import { emit } from "$lib/sockets"; import { SATS, bip21, fail, getUser } from "$lib/utils"; import rpc from "@coinos/rpc"; import { v4 } from "uuid"; +import { PaymentType } from "$lib/types"; + const bc = rpc(config.bitcoin); const lq = rpc(config.liquid); @@ -27,7 +28,7 @@ export const generate = async ({ invoice, user }) => { memo, memoPrompt, prompt, - type = types.lightning, + type = PaymentType.lightning, webhook, secret, } = invoice; @@ -65,7 +66,7 @@ export const generate = async ({ invoice, user }) => { text = bip21(hash, invoice); ({ hdkeypath: path } = await node.getAddressInfo(hash)); - } else if (type === types.lightning) { + } else if (type === PaymentType.lightning) { let r; if (bolt11) { const { id: nodeid } = await ln.getinfo(); @@ -87,7 +88,7 @@ export const generate = async ({ invoice, user }) => { hash = r.bolt11; text = r.bolt11; - } else if (type === types.bolt12) { + } else if (type === PaymentType.bolt12) { const r = await ln.offer({ amount: amount ? `${amount + tip}sat` : "any", label: id, @@ -100,17 +101,17 @@ export const generate = async ({ invoice, user }) => { text = r.bolt12; await s(`invoice:${r.offer_id}`, id); - } else if (type === types.bitcoin) { + } else if (type === PaymentType.bitcoin) { address_type ||= "bech32"; hash = await bc.getNewAddress({ address_type }); text = bip21(hash, invoice); - } else if (type === types.liquid) { + } else if (type === PaymentType.liquid) { address_type ||= "blech32"; hash = await lq.getNewAddress({ address_type }); text = bip21(hash, invoice); - } else if (type === types.internal) { + } else if (type === PaymentType.internal) { hash = id; - } else if (type === types.ecash) { + } else if (type === PaymentType.ecash) { hash = id; text = request(id, amount, memo); } else { |
