diff options
| author | Adam Soltys <[email protected]> | 2024-09-05 12:12:39 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-09-05 12:12:39 -0700 |
| commit | ac63d9cb30690f335616aa046e2b6512b05ecb44 (patch) | |
| tree | 654bedd4409fb3298d042141cc3d23c130ab29f2 /lib/invoices.ts | |
| parent | 33d67e431416ea8b69b424e7d043ef63953c355a (diff) | |
| download | coinos-server-ac63d9cb30690f335616aa046e2b6512b05ecb44.tar.gz coinos-server-ac63d9cb30690f335616aa046e2b6512b05ecb44.zip | |
update sample config
Diffstat (limited to 'lib/invoices.ts')
| -rw-r--r-- | lib/invoices.ts | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/invoices.ts b/lib/invoices.ts index ee0eb73d..1532271e 100644 --- a/lib/invoices.ts +++ b/lib/invoices.ts @@ -1,8 +1,10 @@ +import config from "$config"; import { emit } from "$lib/sockets"; import { db, g, s } from "$lib/db"; import { getUser, bip21, fail, SATS } from "$lib/utils"; import { types } from "$lib/payments"; import { v4 } from "uuid"; +import rpc from "$lib/rpc"; import bc_ from "$lib/bitcoin"; import lq_ from "$lib/liquid"; @@ -14,6 +16,7 @@ let lq = lq_ as any; export let generate = async ({ invoice, user, sender = undefined }) => { let { bolt11, + account, currency, expiry, fiat, @@ -49,7 +52,12 @@ export let generate = async ({ invoice, user, sender = undefined }) => { let id = v4(); let hash, text; - if (type === types.lightning) { + + if (account) { + bc = rpc({...config.bitcoin, wallet: account }); + hash = await bc.getNewAddress(); + text = bip21(hash, invoice); + } else if (type === types.lightning) { let r; if (bolt11) { let { id: nodeid } = await ln.getinfo(); @@ -84,6 +92,7 @@ export let generate = async ({ invoice, user, sender = undefined }) => { invoice = { amount, + account, created: Date.now(), currency, hash, |
