qt tx dialog: small fee edit fix
scenario: enter extremely high feerate (which we cannot satisfy) then click into fee_edit. At that moment, fee_edit is empty and both feerate_edit and fee_edit are considered frozen. As fee_edit has priority, we would construct a tx with default fee. Now, instead, we won't construct this default fee tx ~as if the click to fee_edit did not happen.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, Qt
|
from PyQt5.QtCore import pyqtSignal, Qt
|
||||||
from PyQt5.QtGui import QPalette, QPainter
|
from PyQt5.QtGui import QPalette, QPainter
|
||||||
@@ -71,7 +72,7 @@ class AmountEdit(MyLineEdit):
|
|||||||
painter.setPen(self.help_palette.brush(QPalette.Disabled, QPalette.Text).color())
|
painter.setPen(self.help_palette.brush(QPalette.Disabled, QPalette.Text).color())
|
||||||
painter.drawText(textRect, Qt.AlignRight | Qt.AlignVCenter, self.base_unit())
|
painter.drawText(textRect, Qt.AlignRight | Qt.AlignVCenter, self.base_unit())
|
||||||
|
|
||||||
def get_amount(self):
|
def get_amount(self) -> Union[None, Decimal, int]:
|
||||||
try:
|
try:
|
||||||
return (int if self.is_int else Decimal)(str(self.text()))
|
return (int if self.is_int else Decimal)(str(self.text()))
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -693,9 +693,9 @@ class PreviewTxDialog(BaseTxDialog, TxEditor):
|
|||||||
.format(num_satoshis_added))
|
.format(num_satoshis_added))
|
||||||
|
|
||||||
def get_fee_estimator(self):
|
def get_fee_estimator(self):
|
||||||
if self.is_send_fee_frozen():
|
if self.is_send_fee_frozen() and self.fee_e.get_amount() is not None:
|
||||||
fee_estimator = self.fee_e.get_amount()
|
fee_estimator = self.fee_e.get_amount()
|
||||||
elif self.is_send_feerate_frozen():
|
elif self.is_send_feerate_frozen() and self.feerate_e.get_amount() is not None:
|
||||||
amount = self.feerate_e.get_amount() # sat/byte feerate
|
amount = self.feerate_e.get_amount() # sat/byte feerate
|
||||||
amount = 0 if amount is None else amount * 1000 # sat/kilobyte feerate
|
amount = 0 if amount is None else amount * 1000 # sat/kilobyte feerate
|
||||||
fee_estimator = partial(
|
fee_estimator = partial(
|
||||||
|
|||||||
@@ -642,7 +642,7 @@ def format_fee_satoshis(fee, *, num_zeros=0, precision=None):
|
|||||||
return format_satoshis(fee, num_zeros=num_zeros, decimal_point=0, precision=precision)
|
return format_satoshis(fee, num_zeros=num_zeros, decimal_point=0, precision=precision)
|
||||||
|
|
||||||
|
|
||||||
def quantize_feerate(fee):
|
def quantize_feerate(fee) -> Union[None, Decimal, int]:
|
||||||
"""Strip sat/byte fee rate of excess precision."""
|
"""Strip sat/byte fee rate of excess precision."""
|
||||||
if fee is None:
|
if fee is None:
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user