fix(wallet): stop double-deducting balance on outgoing payments #109
No reviewers
Labels
No labels
app:activities
app:chat
app:events
app:forum
app:libra
app:market
app:restaurant
app:tasks
app:wallet
app:webapp
bug
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aiolabs/webapp!109
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/wallet-double-deduct-balance"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Sending a payment deducts the displayed balance twice: with 100 sats, sending 10 shows 80. A page refresh corrects it to the right value (90), so the bug is purely in the live in-memory balance, not the backend.
Root cause
WalletWebSocketService.handleMessageassumed LNbits sends the pre-payment balance for outgoing payments and subtracted the amount again:But LNbits emits the post-payment balance for both directions. It re-fetches the wallet after the payment settles before sending the notification:
core/services/payments.py_send_payment_notification_in_background→# fetch balance again→get_wallet(...)core/services/notifications.pysend_ws_payment_notification→"wallet_balance": wallet.balanceSo
wallet_balanceis already90for our example, and subtracting10again yields80. The refresh reads the authoritative/api/v1/walletbalance (90), which is why it self-corrects.Fix
Use
wallet_balanceas-is for all messages — no per-direction adjustment. This matches the polling fallback in the same file, which already trusts the/api/v1/walletbalance directly.Test notes
vue-tsc --noEmitclean for the changed file.🤖 Generated with Claude Code
be3ac55f1dtofddc26387e