diff --git a/static/js/index.js b/static/js/index.js index 318483b..a0b38ba 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -1338,20 +1338,24 @@ window.app = Vue.createApp({ const fiatCurrency = Object.keys(fiatBalances)[0] || null const fiatAmount = fiatCurrency ? fiatBalances[fiatCurrency] : 0 + // Use absolute values since balance is negative (liability = castle owes user) + const maxAmountSats = Math.abs(userBalance.balance) + const maxAmountFiat = Math.abs(fiatAmount) + this.payUserDialog = { show: true, user_id: userBalance.user_id, username: userBalance.username, - maxAmount: userBalance.balance, // Positive sats amount castle owes - maxAmountFiat: fiatAmount, // EUR or other fiat amount + maxAmount: maxAmountSats, // Positive sats amount castle owes + maxAmountFiat: maxAmountFiat, // EUR or other fiat amount (positive) fiatCurrency: fiatCurrency, - amount: fiatCurrency ? fiatAmount : userBalance.balance, // Default to fiat if available + amount: fiatCurrency ? maxAmountFiat : maxAmountSats, // Default to fiat if available payment_method: 'lightning', // Default to lightning for paying description: '', reference: '', loading: false, paymentSuccess: false, - exchangeRate: fiatAmount > 0 ? userBalance.balance / fiatAmount : this.currentExchangeRate, + exchangeRate: maxAmountFiat > 0 ? maxAmountSats / maxAmountFiat : this.currentExchangeRate, originalCurrency: fiatCurrency || 'BTC' } },