diff --git a/src/components/PaymentConfirmModal.tsx b/src/components/PaymentConfirmModal.tsx index 3a7ac8f97..5b5f1520e 100644 --- a/src/components/PaymentConfirmModal.tsx +++ b/src/components/PaymentConfirmModal.tsx @@ -11,6 +11,13 @@ import { AmountSats } from '../libs/JmWalletApi' import { jarInitial } from './jars/Jar' import { isValidNumber } from '../utils' +const feeRange: (feeValues: FeeValues) => [number, number] = (feeValues) => { + const feeTargetInSatsPerVByte = feeValues.tx_fees! / 1_000 + const minFeeSatsPerVByte = Math.max(1, feeTargetInSatsPerVByte) + const maxFeeSatsPerVByte = feeTargetInSatsPerVByte * (1 + feeValues.tx_fees_factor!) + return [minFeeSatsPerVByte, maxFeeSatsPerVByte] +} + const useMiningFeeText = ({ feeConfigValues }: { feeConfigValues?: FeeValues }) => { const { t } = useTranslation() @@ -24,24 +31,23 @@ const useMiningFeeText = ({ feeConfigValues }: { feeConfigValues?: FeeValues }) } else if (unit === 'blocks') { return t('send.confirm_send_modal.text_miner_fee_in_targeted_blocks', { count: feeConfigValues.tx_fees }) } else { - const feeTargetInSatsPerVByte = feeConfigValues.tx_fees! / 1_000 - if (feeConfigValues.tx_fees_factor === 0) { + const [minFeeSatsPerVByte, maxFeeSatsPerVByte] = feeRange(feeConfigValues) + const fractionDigits = 2 + + if (minFeeSatsPerVByte.toFixed(fractionDigits) === maxFeeSatsPerVByte.toFixed(fractionDigits)) { return t('send.confirm_send_modal.text_miner_fee_in_satspervbyte_exact', { - value: feeTargetInSatsPerVByte.toLocaleString(undefined, { + value: minFeeSatsPerVByte.toLocaleString(undefined, { maximumFractionDigits: Math.log10(1_000), }), }) } - const minFeeSatsPerVByte = Math.max(1, feeTargetInSatsPerVByte * (1 - feeConfigValues.tx_fees_factor!)) - const maxFeeSatsPerVByte = feeTargetInSatsPerVByte * (1 + feeConfigValues.tx_fees_factor!) - return t('send.confirm_send_modal.text_miner_fee_in_satspervbyte_randomized', { min: minFeeSatsPerVByte.toLocaleString(undefined, { - maximumFractionDigits: 1, + maximumFractionDigits: fractionDigits, }), max: maxFeeSatsPerVByte.toLocaleString(undefined, { - maximumFractionDigits: 1, + maximumFractionDigits: fractionDigits, }), }) } diff --git a/src/components/settings/FeeConfigModal.tsx b/src/components/settings/FeeConfigModal.tsx index a1f6f37ad..41b1c0094 100644 --- a/src/components/settings/FeeConfigModal.tsx +++ b/src/components/settings/FeeConfigModal.tsx @@ -278,7 +278,7 @@ const FeeConfigForm = forwardRef( : '', })} - {t('settings.fees.description_tx_fees_factor')} + {t('settings.fees.description_tx_fees_factor_^0.9.10')} % diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json index 5f377b345..aeafa2573 100644 --- a/src/i18n/locales/en/translation.json +++ b/src/i18n/locales/en/translation.json @@ -239,7 +239,7 @@ "feedback_invalid_tx_fees_blocks": "Please provide a valid block target between {{ min }} and {{ max }}.", "feedback_invalid_tx_fees_satspervbyte": "Please provide a valid transaction fee in sats/vByte between {{ min }} and {{ max }}.", "label_tx_fees_factor": "Fee randomization", - "description_tx_fees_factor": "Random fees improve privacy. The percentage is to be understood as a +/- around the base fee. Example: If you set the base fee to 10 sats/vByte and the randomization to 30%, a value between 7 and 13 sats/vByte will be used. Default: 20%.", + "description_tx_fees_factor_^0.9.10": "Random fees improve privacy. The percentage is an upward randomization factor of the base fee. Example: If you set the base fee to 10 sats/vByte and the randomization to 30%, a value between 10 and 13 sats/vByte will be used. Default: 20%.", "feedback_invalid_tx_fees_factor": "Please provide a valid fee randomization value between {{ min }} and {{ max }}.", "title_max_cj_fee_settings": "Collaborator fees", "description_max_cj_fee_settings": "Collaborator fees relate to liquidity price and depend on market conditions. Total fees paid for each transaction depend on the amount of collaborators. Additional collaborators increase privacy, but also fees.",