Fix fee added to received amount (#1582)

This commit is contained in:
ekzyis 2024-11-13 02:50:15 +01:00 committed by GitHub
parent 08c29b9f10
commit b7fc0e0e74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -285,9 +285,12 @@ export async function paidActionForwarded ({ data: { invoiceId, withdrawal, ...a
// settle the invoice, allowing us to transition to PAID
await settleHodlInvoice({ secret: payment.secret, lnd })
// the amount we paid includes the fee so we need to subtract it to get the amount received
const received = Number(payment.mtokens) - Number(payment.fee_mtokens)
const logger = walletLogger({ wallet: dbInvoice.invoiceForward.wallet, models })
logger.ok(
`↙ payment received: ${formatSats(msatsToSats(payment.mtokens))}`,
`↙ payment received: ${formatSats(msatsToSats(received))}`,
{
bolt11,
preimage: payment.secret

View File

@ -309,8 +309,9 @@ export async function checkWithdrawal ({ data: { hash, withdrawal, invoice }, bo
notifyWithdrawal(dbWdrwl.userId, wdrwl)
const { request: bolt11, secret: preimage } = wdrwl.payment
logger?.ok(
`↙ payment received: ${formatSats(msatsToSats(Number(wdrwl.payment.mtokens)))}`,
`↙ payment received: ${formatSats(msatsToSats(paid))}`,
{
bolt11,
preimage,