diff options
Diffstat (limited to 'lib/payments.ts')
| -rw-r--r-- | lib/payments.ts | 13 |
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 |
