diff options
| author | Adam Soltys <[email protected]> | 2026-02-04 13:05:01 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-06 08:59:26 -0800 |
| commit | 384c4778ca5421c091a7d282b90b00965f3596cd (patch) | |
| tree | 0803cb8872128007e5487f94a9b9e7a00cbffba6 /lib/invoices.ts | |
| parent | 5e3bfba5eb3d54cc03551f98624a2e92dca5825f (diff) | |
| download | coinos-server-384c4778ca5421c091a7d282b90b00965f3596cd.tar.gz coinos-server-384c4778ca5421c091a7d282b90b00965f3596cd.zip | |
zmq logic
Diffstat (limited to 'lib/invoices.ts')
| -rw-r--r-- | lib/invoices.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/invoices.ts b/lib/invoices.ts index 50cddd9a..4a9d5c89 100644 --- a/lib/invoices.ts +++ b/lib/invoices.ts @@ -1,6 +1,7 @@ import config from "$config"; import { db, g, s } from "$lib/db"; import { request } from "$lib/ecash"; +import { deriveAddress } from "$lib/esplora"; import ln from "$lib/ln"; import { emit } from "$lib/sockets"; import { SATS, bip21, fail, getInvoice, getUser } from "$lib/utils"; @@ -68,11 +69,16 @@ export const generate = async ({ invoice, user }) => { text = account.arkAddress; } else if (account.seed) { type = PaymentType.bitcoin; - const node = rpc({ ...config[type], wallet: aid }); - hash = await node.getNewAddress({ address_type }); + const nextIndex = account.nextIndex || 0; + const { address, path: hdpath } = deriveAddress(account.pubkey, account.fingerprint, nextIndex); + hash = address; + path = hdpath; text = bip21(hash, invoice); - ({ hdkeypath: path } = await node.getAddressInfo(hash)); + account.nextIndex = nextIndex + 1; + await s(`account:${aid}`, account); + await s(`invoice:${hash}`, id); + await db.sAdd("watching", hash); } else if (type === PaymentType.lightning) { let r; if (bolt11) { |
