|
|
@ -10,16 +10,18 @@ from electrum.gui.kivy.i18n import _ |
|
|
|
if TYPE_CHECKING: |
|
|
|
from ...main_window import ElectrumWindow |
|
|
|
|
|
|
|
from .fee_dialog import FeeSliderDialog |
|
|
|
|
|
|
|
|
|
|
|
Builder.load_string(''' |
|
|
|
<BumpFeeDialog@Popup> |
|
|
|
title: _('Bump fee') |
|
|
|
size_hint: 0.8, 0.8 |
|
|
|
pos_hint: {'top':0.9} |
|
|
|
method: 0 |
|
|
|
BoxLayout: |
|
|
|
orientation: 'vertical' |
|
|
|
padding: '10dp' |
|
|
|
|
|
|
|
GridLayout: |
|
|
|
height: self.minimum_height |
|
|
|
size_hint_y: None |
|
|
@ -33,14 +35,24 @@ Builder.load_string(''' |
|
|
|
id: old_feerate |
|
|
|
text: _('Current Fee rate') |
|
|
|
value: '' |
|
|
|
BoxLabel: |
|
|
|
id: new_feerate |
|
|
|
text: _('New Fee rate') |
|
|
|
value: '' |
|
|
|
BoxLayout: |
|
|
|
orientation: 'horizontal' |
|
|
|
size_hint: 1, 0.5 |
|
|
|
Label: |
|
|
|
id: tooltip1 |
|
|
|
text: '' |
|
|
|
size_hint_y: None |
|
|
|
Label: |
|
|
|
id: tooltip2 |
|
|
|
text: _('Target') + ' (%s):' % (_('mempool') if root.method == 2 else _('ETA') if root.method == 1 else _('static')) |
|
|
|
Button: |
|
|
|
id: fee_target |
|
|
|
text: '' |
|
|
|
size_hint_y: None |
|
|
|
background_color: (0,0,0,0) |
|
|
|
bold: True |
|
|
|
on_release: |
|
|
|
root.method = (root.method + 1) % 3 |
|
|
|
root.update_slider() |
|
|
|
root.update_text() |
|
|
|
Slider: |
|
|
|
id: slider |
|
|
|
range: 0, 4 |
|
|
@ -72,48 +84,32 @@ Builder.load_string(''' |
|
|
|
root.on_ok() |
|
|
|
''') |
|
|
|
|
|
|
|
class BumpFeeDialog(Factory.Popup): |
|
|
|
class BumpFeeDialog(FeeSliderDialog, Factory.Popup): |
|
|
|
|
|
|
|
def __init__(self, app: 'ElectrumWindow', fee, size, callback): |
|
|
|
Factory.Popup.__init__(self) |
|
|
|
FeeSliderDialog.__init__(self, app.electrum_config, self.ids.slider) |
|
|
|
self.app = app |
|
|
|
self.init_fee = fee |
|
|
|
self.tx_size = size |
|
|
|
self.callback = callback |
|
|
|
self.config = app.electrum_config |
|
|
|
self.mempool = self.config.use_mempool_fees() |
|
|
|
self.dynfees = self.config.is_dynfee() and bool(self.app.network) and self.config.has_dynamic_fees_ready() |
|
|
|
self.ids.old_fee.value = self.app.format_amount_and_units(self.init_fee) |
|
|
|
self.ids.old_feerate.value = self.app.format_fee_rate(fee / self.tx_size * 1000) |
|
|
|
self.update_slider() |
|
|
|
self.update_text() |
|
|
|
|
|
|
|
def update_text(self): |
|
|
|
pos = int(self.ids.slider.value) |
|
|
|
new_fee_rate = self.get_fee_rate() |
|
|
|
text, tooltip = self.config.get_fee_text(pos, self.dynfees, self.mempool, new_fee_rate) |
|
|
|
self.ids.tooltip1.text = text |
|
|
|
self.ids.tooltip2.text = tooltip |
|
|
|
|
|
|
|
def update_slider(self): |
|
|
|
slider = self.ids.slider |
|
|
|
maxp, pos, fee_rate = self.config.get_fee_slider(self.dynfees, self.mempool) |
|
|
|
slider.range = (0, maxp) |
|
|
|
slider.step = 1 |
|
|
|
slider.value = pos |
|
|
|
|
|
|
|
def get_fee_rate(self): |
|
|
|
pos = int(self.ids.slider.value) |
|
|
|
if self.dynfees: |
|
|
|
fee_rate = self.config.depth_to_fee(pos) if self.mempool else self.config.eta_to_fee(pos) |
|
|
|
else: |
|
|
|
fee_rate = self.config.static_fee(pos) |
|
|
|
return fee_rate # sat/kbyte |
|
|
|
target, tooltip, dyn = self.config.get_fee_target() |
|
|
|
self.ids.fee_target.text = target |
|
|
|
feerate = self.config.fee_per_kb() / 1000 |
|
|
|
self.ids.new_feerate.value = f'{feerate:.1f} sat/B' |
|
|
|
|
|
|
|
def on_ok(self): |
|
|
|
new_fee_rate = self.get_fee_rate() / 1000 |
|
|
|
new_fee_rate = self.config.fee_per_kb() / 1000 |
|
|
|
is_final = self.ids.final_cb.active |
|
|
|
self.callback(new_fee_rate, is_final) |
|
|
|
|
|
|
|
def on_slider(self, value): |
|
|
|
self.save_config() |
|
|
|
self.update_text() |
|
|
|