Skip to content

Commit

Permalink
Merge pull request #2257 from kaloudis/getFormattedAmount-fix
Browse files Browse the repository at this point in the history
getFormattedAmount: fix BTC decimal amounts
  • Loading branch information
kaloudis authored Jun 21, 2024
2 parents d1b62b4 + 0a6e872 commit 3e460d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions stores/UnitsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,17 @@ export default class UnitsStore {
const { fiat } = settings;
const units = fixedUnits || this.units;

const [wholeSats] = value.toString().split('.');
if (units === 'BTC') {
// handle negative values
const valueToProcess = (wholeSats && wholeSats.toString()) || '0';
const valueToProcess = value.toString() || '0';
if (valueToProcess.includes('-')) {
const processedValue = valueToProcess.split('-')[1];
return `-₿${FeeUtils.toFixed(Number(processedValue))}`;
}

return `₿${FeeUtils.toFixed(Number(wholeSats || 0))}`;
return `₿${FeeUtils.toFixed(Number(value || 0))}`;
} else if (units === 'sats') {
const [wholeSats] = value.toString().split('.');
const sats = `${
this.fiatStore.numberWithCommas(wholeSats || value) || 0
} ${Number(value) === 1 || Number(value) === -1 ? 'sat' : 'sats'}`;
Expand Down

0 comments on commit 3e460d4

Please sign in to comment.