|
@ -23,6 +23,7 @@ |
|
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
|
# SOFTWARE. |
|
|
# SOFTWARE. |
|
|
|
|
|
|
|
|
|
|
|
from decimal import Decimal |
|
|
from typing import TYPE_CHECKING, Optional, Union |
|
|
from typing import TYPE_CHECKING, Optional, Union |
|
|
|
|
|
|
|
|
from PyQt5.QtWidgets import QVBoxLayout, QLabel, QGridLayout, QPushButton, QLineEdit |
|
|
from PyQt5.QtWidgets import QVBoxLayout, QLabel, QGridLayout, QPushButton, QLineEdit |
|
@ -31,7 +32,7 @@ from electrum.i18n import _ |
|
|
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates |
|
|
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates |
|
|
from electrum.plugin import run_hook |
|
|
from electrum.plugin import run_hook |
|
|
from electrum.transaction import Transaction, PartialTransaction |
|
|
from electrum.transaction import Transaction, PartialTransaction |
|
|
from electrum.simple_config import FEERATE_WARNING_HIGH_FEE |
|
|
from electrum.simple_config import FEERATE_WARNING_HIGH_FEE, FEE_RATIO_HIGH_WARNING |
|
|
from electrum.wallet import InternalAddressCorruption |
|
|
from electrum.wallet import InternalAddressCorruption |
|
|
|
|
|
|
|
|
from .util import (WindowModalDialog, ColorScheme, HelpLabel, Buttons, CancelButton, |
|
|
from .util import (WindowModalDialog, ColorScheme, HelpLabel, Buttons, CancelButton, |
|
@ -240,17 +241,22 @@ class ConfirmTxDialog(TxEditor, WindowModalDialog): |
|
|
self.extra_fee_value.setVisible(True) |
|
|
self.extra_fee_value.setVisible(True) |
|
|
self.extra_fee_value.setText(self.main_window.format_amount_and_units(x_fee_amount)) |
|
|
self.extra_fee_value.setText(self.main_window.format_amount_and_units(x_fee_amount)) |
|
|
|
|
|
|
|
|
feerate_warning = FEERATE_WARNING_HIGH_FEE |
|
|
amount = tx.output_value() if self.output_value == '!' else self.output_value |
|
|
low_fee = fee < self.wallet.relayfee() * tx.estimated_size() / 1000 |
|
|
feerate = Decimal(fee) / tx.estimated_size() # sat/byte |
|
|
high_fee = fee > feerate_warning * tx.estimated_size() / 1000 |
|
|
fee_ratio = Decimal(fee) / amount if amount else 1 |
|
|
if low_fee: |
|
|
if feerate < self.wallet.relayfee() / 1000: |
|
|
msg = '\n'.join([ |
|
|
msg = '\n'.join([ |
|
|
_("This transaction requires a higher fee, or it will not be propagated by your current server"), |
|
|
_("This transaction requires a higher fee, or it will not be propagated by your current server"), |
|
|
_("Try to raise your transaction fee, or use a server with a lower relay fee.") |
|
|
_("Try to raise your transaction fee, or use a server with a lower relay fee.") |
|
|
]) |
|
|
]) |
|
|
self.toggle_send_button(False, message=msg) |
|
|
self.toggle_send_button(False, message=msg) |
|
|
elif high_fee: |
|
|
elif fee_ratio >= FEE_RATIO_HIGH_WARNING: |
|
|
self.toggle_send_button(True, |
|
|
self.toggle_send_button(True, |
|
|
message=_('Warning') + ': ' + _("The fee for this transaction seems unusually high.")) |
|
|
message=_('Warning') + ': ' + _("The fee for this transaction seems unusually high.") |
|
|
|
|
|
+ f'\n({fee_ratio*100:.2f}% of amount)') |
|
|
|
|
|
elif feerate > FEERATE_WARNING_HIGH_FEE / 1000: |
|
|
|
|
|
self.toggle_send_button(True, |
|
|
|
|
|
message=_('Warning') + ': ' + _("The fee for this transaction seems unusually high.") |
|
|
|
|
|
+ f'\n(feerate: {feerate:.2f} sat/byte)') |
|
|
else: |
|
|
else: |
|
|
self.toggle_send_button(True) |
|
|
self.toggle_send_button(True) |
|
|