diff options
Diffstat (limited to 'lib/invoices.ts')
| -rw-r--r-- | lib/invoices.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/invoices.ts b/lib/invoices.ts index bf6c511e..f7bb6897 100644 --- a/lib/invoices.ts +++ b/lib/invoices.ts @@ -69,9 +69,25 @@ export const generate = async ({ invoice, user }) => { let path; let paymentHash; - if (account.type === "ark") { + if (type === PaymentType.ark && account.type !== "ark") { + // Custodial account receiving via Ark: use vault's ark address + const accounts = await db.lRange(`${user.id}:accounts`, 0, -1); + let vaultAddress; + for (const accId of accounts) { + const acc = await g(`account:${accId}`); + if (acc?.type === "ark" && acc.arkAddress) { + vaultAddress = acc.arkAddress; + break; + } + } + if (!vaultAddress) fail("No ark vault found"); + text = vaultAddress; + hash = id; + await s(`custodial-ark-invoice:${vaultAddress}`, id); + } else if (account.type === "ark") { type = PaymentType.ark; text = account.arkAddress; + hash = id; } else if (account.seed || (account.pubkey && account.fingerprint)) { type = PaymentType.bitcoin; const nextIndex = account.nextIndex || 0; |
