Merge pull request #1714 from stackernews/1704-fix-exposed-routing-fees

Don't expose p2p zap receivers to routing fees
This commit is contained in:
Keyan 2024-12-11 15:47:57 -06:00 committed by GitHub
commit 6918bcb452
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 6 deletions

View File

@ -501,13 +501,23 @@ function Invoicification ({ n: { invoice, sortTime } }) {
}
function WithdrawlPaid ({ n }) {
let actionString = n.withdrawl.autoWithdraw ? 'sent to your attached wallet' : 'withdrawn from your account'
let amount = n.earnedSats + n.withdrawl.satsFeePaid
let actionString = 'withdrawn from your account'
if (n.withdrawl.autoWithdraw) {
actionString = 'sent to your attached wallet'
}
if (n.withdrawl.forwardedActionType === 'ZAP') {
// don't expose receivers to routing fees they aren't paying
amount = n.earnedSats
actionString = 'zapped directly to your attached wallet'
}
return (
<div className='fw-bold text-info'>
<Check className='fill-info me-1' />{numWithUnits(n.earnedSats + n.withdrawl.satsFeePaid, { abbreviate: false, unitSingular: 'sat was ', unitPlural: 'sats were ' })}
<Check className='fill-info me-1' />
{numWithUnits(amount, { abbreviate: false, unitSingular: 'sat was ', unitPlural: 'sats were ' })}
{actionString}
<small className='text-muted ms-1 fw-normal' suppressHydrationWarning>{timeSince(new Date(n.sortTime))}</small>
{(n.withdrawl.forwardedActionType === 'ZAP' && <Badge className={styles.badge} bg={null}>p2p</Badge>) ||

View File

@ -317,13 +317,11 @@ export async function paidActionForwarded ({ data: { invoiceId, withdrawal, ...a
}, { models, lnd, boss })
if (transitionedInvoice) {
const { bolt11, msatsPaid, msatsFeePaid } = transitionedInvoice.invoiceForward.withdrawl
// the amount we paid includes the fee so we need to subtract it to get the amount received
const received = Number(msatsPaid) - Number(msatsFeePaid)
const { bolt11, msatsPaid } = transitionedInvoice.invoiceForward.withdrawl
const logger = walletLogger({ wallet: transitionedInvoice.invoiceForward.wallet, models })
logger.ok(
`↙ payment received: ${formatSats(msatsToSats(received))}`,
`↙ payment received: ${formatSats(msatsToSats(Number(msatsPaid)))}`,
{
bolt11,
preimage: transitionedInvoice.preimage