aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-15 00:15:06 -0800
committerAdam Soltys <[email protected]>2026-02-15 00:15:06 -0800
commit4a0fcb5f851190eccc7a33907a180ee584db583c (patch)
tree0cc38f2c86a1ce08e3220ccea27f8c2323a855c0
parent526b21bc668c453250ebce8dece9ba330bac0133 (diff)
downloadcoinos-server-4a0fcb5f851190eccc7a33907a180ee584db583c.tar.gz
coinos-server-4a0fcb5f851190eccc7a33907a180ee584db583c.zip
fix custodial sends
-rw-r--r--lib/payments.ts16
-rw-r--r--routes/payments.ts27
2 files changed, 24 insertions, 19 deletions
diff --git a/lib/payments.ts b/lib/payments.ts
index 03b52dfa..8fee1a26 100644
--- a/lib/payments.ts
+++ b/lib/payments.ts
@@ -520,12 +520,20 @@ const pay = async ({ aid = undefined, amount, to, user }) => {
});
if (to.startsWith("ark") || to.startsWith("tark")) {
- // Check for local vault - do internal transfer
+ // Check for local custodial receive - do internal transfer
const vault = await g(`arkaddr:${to}`);
if (vault) {
- const recipient = await getUser(vault.uid);
- if (recipient)
- return sendInternal({ amount, recipient, sender: user });
+ const vaultAccount = await g(`account:${vault.aid}`);
+ if (vaultAccount?.arkAddress) {
+ const iid = await g(`custodial-ark-invoice:${vaultAccount.arkAddress}`);
+ if (iid) {
+ const invoice = await getInvoice(iid);
+ if (invoice && !invoice.hash) invoice.hash = invoice.id;
+ const recipient = await getUser(vault.uid);
+ if (recipient && invoice)
+ return sendInternal({ amount, invoice, recipient, sender: user });
+ }
+ }
}
const txid = await sendArk(to, amount);
diff --git a/routes/payments.ts b/routes/payments.ts
index 5f6f7a85..dfc6c20d 100644
--- a/routes/payments.ts
+++ b/routes/payments.ts
@@ -774,25 +774,22 @@ export default {
try {
await requirePin({ body, user });
- // Check for local vault - do internal transfer
+ // Check for local custodial receive - do internal transfer
const vault = await g(`arkaddr:${address}`);
if (vault) {
- const recipient = await getUser(vault.uid);
- if (recipient) {
- // Find recipient's pending ark invoice via custodial mapping
- let invoice;
- const account = await g(`account:${vault.aid}`);
- if (account?.arkAddress) {
- const iid = await g(`custodial-ark-invoice:${account.arkAddress}`);
- if (iid) {
- invoice = await getInvoice(iid);
- if (invoice && !invoice.hash) invoice.hash = invoice.id;
+ const account = await g(`account:${vault.aid}`);
+ if (account?.arkAddress) {
+ const iid = await g(`custodial-ark-invoice:${account.arkAddress}`);
+ if (iid) {
+ const invoice = await getInvoice(iid);
+ if (invoice && !invoice.hash) invoice.hash = invoice.id;
+ const recipient = await getUser(vault.uid);
+ if (recipient && invoice) {
+ l("ark local send", user.username, recipient.username, amount);
+ const p = await sendInternal({ amount, invoice, recipient, sender: user });
+ return res.send(p);
}
}
-
- l("ark local send", user.username, recipient.username, amount, "invoice:", invoice?.id, "received:", invoice?.received, "hash:", invoice?.hash);
- const p = await sendInternal({ amount, invoice, recipient, sender: user });
- return res.send(p);
}
}