Skip to content

Commit

Permalink
Fix fee added to received amount (#1582)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis authored Nov 13, 2024
1 parent 08c29b9 commit b7fc0e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion worker/paidAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion worker/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b7fc0e0

Please sign in to comment.