aboutsummaryrefslogtreecommitdiffstats
path: root/lib/payments.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-07-11 09:17:05 -0700
committerAdam Soltys <[email protected]>2026-07-11 09:17:05 -0700
commit2e90d709178ac718e4f32229951e6ea38dfcc371 (patch)
tree3724e212ba6b4eaa15f1326086c6badb0f4f4e4e /lib/payments.ts
parentb9791efba00cd00837699fba92a8d27528968395 (diff)
parentd466aab4451a89b2d69a2618f0a739b2e89903c5 (diff)
downloadcoinos-server-2e90d709178ac718e4f32229951e6ea38dfcc371.tar.gz
coinos-server-2e90d709178ac718e4f32229951e6ea38dfcc371.zip
Merge remote-tracking branch 'origin/master'
# Conflicts: # lib/payments.ts
Diffstat (limited to 'lib/payments.ts')
-rw-r--r--lib/payments.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/payments.ts b/lib/payments.ts
index c256171c..01de2eff 100644
--- a/lib/payments.ts
+++ b/lib/payments.ts
@@ -289,6 +289,19 @@ export const credit = async ({
return;
}
+ // usePreimage invoices keep their merchant-supplied preimage at
+ // preimage:${paymentHash} (see generate()). Prefer it as the settlement
+ // ref: external settlements already carry the same value, but internal
+ // ones pass ref=sender.id, which would otherwise be surfaced as the
+ // payment preimage and lose the secret the buyer paid for.
+ if (
+ inv.paymentHash &&
+ ![PaymentType.bitcoin, PaymentType.liquid].includes(type)
+ ) {
+ const stored = await db.get(`preimage:${inv.paymentHash}`);
+ if (stored) ref = stored;
+ }
+
let { path } = inv;
// Use the tip the sender was actually debited (passed in for internal
// transfers) rather than re-reading the invoice. The invoice's tip can be