Browse Source

qml: implement RbF bump methods Decrease payment/Preserve payment

extend FormattedAmount to wrap alt to next line, or show as empty when invalid
master
Sander van Grieken 3 years ago
parent
commit
a986e61047
  1. 116
      electrum/gui/qml/components/RbfBumpFeeDialog.qml
  2. 12
      electrum/gui/qml/components/TxDetails.qml
  3. 22
      electrum/gui/qml/components/controls/FormattedAmount.qml
  4. 14
      electrum/gui/qml/qetxfinalizer.py

116
electrum/gui/qml/components/RbfBumpFeeDialog.qml

@ -30,8 +30,7 @@ ElDialog {
} }
ColumnLayout { ColumnLayout {
width: parent.width anchors.fill: parent
height: parent.height
spacing: 0 spacing: 0
GridLayout { GridLayout {
@ -41,20 +40,52 @@ ElDialog {
columns: 2 columns: 2
Label { Label {
text: qsTr('Old fee') Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr('Increase your transaction\'s fee to improve its position in the mempool')
wrapMode: Text.Wrap
}
Label {
Layout.preferredWidth: 1
Layout.fillWidth: true
text: qsTr('Method')
color: Material.accentColor color: Material.accentColor
} }
RowLayout { RowLayout {
Label { Layout.preferredWidth: 1
id: oldfee Layout.fillWidth: true
text: Config.formatSats(rbffeebumper.oldfee) ElComboBox {
textRole: 'text'
valueRole: 'value'
model: [
{ text: qsTr('Preserve payment'), value: 'preserve_payment' },
{ text: qsTr('Decrease payment'), value: 'decrease_payment' }
]
onCurrentValueChanged: {
if (activeFocus)
rbffeebumper.bumpMethod = currentValue
}
Component.onCompleted: {
currentIndex = indexOfValue(rbffeebumper.bumpMethod)
}
} }
Item { Layout.fillWidth: true; Layout.preferredHeight: 1 }
}
Label { Label {
text: Config.baseUnit Layout.preferredWidth: 1
color: Material.accentColor Layout.fillWidth: true
} text: qsTr('Old fee')
color: Material.accentColor
}
FormattedAmount {
Layout.preferredWidth: 1
Layout.fillWidth: true
amount: rbffeebumper.oldfee
} }
Label { Label {
@ -66,6 +97,7 @@ ElDialog {
Label { Label {
id: oldfeeRate id: oldfeeRate
text: rbffeebumper.oldfeeRate text: rbffeebumper.oldfeeRate
font.family: FixedFont
} }
Label { Label {
@ -79,17 +111,9 @@ ElDialog {
color: Material.accentColor color: Material.accentColor
} }
RowLayout { FormattedAmount {
Label { amount: rbffeebumper.fee
id: fee valid: rbffeebumper.valid
text: rbffeebumper.valid ? Config.formatSats(rbffeebumper.fee) : ''
}
Label {
visible: rbffeebumper.valid
text: Config.baseUnit
color: Material.accentColor
}
} }
Label { Label {
@ -101,6 +125,7 @@ ElDialog {
Label { Label {
id: feeRate id: feeRate
text: rbffeebumper.valid ? rbffeebumper.feeRate : '' text: rbffeebumper.valid ? rbffeebumper.feeRate : ''
font.family: FixedFont
} }
Label { Label {
@ -120,31 +145,36 @@ ElDialog {
text: rbffeebumper.target text: rbffeebumper.target
} }
Slider { RowLayout {
id: feeslider Layout.columnSpan: 2
leftPadding: constants.paddingMedium Layout.fillWidth: true
snapMode: Slider.SnapOnRelease Slider {
stepSize: 1 id: feeslider
from: 0 Layout.fillWidth: true
to: rbffeebumper.sliderSteps leftPadding: constants.paddingMedium
onValueChanged: { snapMode: Slider.SnapOnRelease
if (activeFocus) stepSize: 1
rbffeebumper.sliderPos = value from: 0
} to: rbffeebumper.sliderSteps
Component.onCompleted: { onValueChanged: {
value = rbffeebumper.sliderPos if (activeFocus)
} rbffeebumper.sliderPos = value
Connections { }
target: rbffeebumper Component.onCompleted: {
function onSliderPosChanged() { value = rbffeebumper.sliderPos
feeslider.value = rbffeebumper.sliderPos }
Connections {
target: rbffeebumper
function onSliderPosChanged() {
feeslider.value = rbffeebumper.sliderPos
}
} }
} }
}
FeeMethodComboBox { FeeMethodComboBox {
id: target id: target
feeslider: rbffeebumper feeslider: rbffeebumper
}
} }
InfoTextArea { InfoTextArea {

12
electrum/gui/qml/components/TxDetails.qml

@ -99,19 +99,9 @@ Pane {
FormattedAmount { FormattedAmount {
visible: !txdetails.isUnrelated visible: !txdetails.isUnrelated
Layout.fillWidth: true Layout.fillWidth: true
showAlt: false
amount: txdetails.lnAmount.isEmpty ? txdetails.amount : txdetails.lnAmount amount: txdetails.lnAmount.isEmpty ? txdetails.amount : txdetails.lnAmount
} }
Item {
visible: !txdetails.isUnrelated && Daemon.fx.enabled; Layout.preferredWidth: 1; Layout.preferredHeight: 1
}
Label {
visible: !txdetails.isUnrelated && Daemon.fx.enabled && txdetails.lnAmount.satsInt == 0
text: Daemon.fx.fiatValue(txdetails.amount, false) + ' ' + Daemon.fx.fiatCurrency
}
Label { Label {
visible: !txdetails.isUnrelated && Daemon.fx.enabled && txdetails.lnAmount.satsInt != 0 visible: !txdetails.isUnrelated && Daemon.fx.enabled && txdetails.lnAmount.satsInt != 0
text: Daemon.fx.fiatValue(txdetails.lnAmount, false) + ' ' + Daemon.fx.fiatCurrency text: Daemon.fx.fiatValue(txdetails.lnAmount, false) + ' ' + Daemon.fx.fiatCurrency
@ -130,7 +120,7 @@ Pane {
FormattedAmount { FormattedAmount {
Layout.fillWidth: true Layout.fillWidth: true
amount: txdetails.fee amount: txdetails.fee
showAlt: false singleLine: !(txdetails.canBump || txdetails.canCpfp)
} }
FlatButton { FlatButton {
Layout.fillWidth: true Layout.fillWidth: true

22
electrum/gui/qml/components/controls/FormattedAmount.qml

@ -5,20 +5,38 @@ import QtQuick.Controls.Material 2.0
import org.electrum 1.0 import org.electrum 1.0
RowLayout { GridLayout {
required property Amount amount required property Amount amount
property bool showAlt: true property bool showAlt: true
property bool singleLine: true
property bool valid: true
columns: !valid
? 1
: singleLine
? 3
: 2
Item {
visible: !valid // empty placeholder if not valid
Layout.preferredWidth: 1
Layout.preferredHeight: 1
}
Label { Label {
visible: valid
text: amount.msatsInt > 0 ? Config.formatMilliSats(amount) : Config.formatSats(amount) text: amount.msatsInt > 0 ? Config.formatMilliSats(amount) : Config.formatSats(amount)
font.family: FixedFont font.family: FixedFont
} }
Label { Label {
visible: valid
text: Config.baseUnit text: Config.baseUnit
color: Material.accentColor color: Material.accentColor
} }
Label { Label {
visible: showAlt && Daemon.fx.enabled Layout.columnSpan: singleLine ? 1 : 2
visible: showAlt && Daemon.fx.enabled && valid
text: '(' + Daemon.fx.fiatValue(amount) + ' ' + Daemon.fx.fiatCurrency + ')' text: '(' + Daemon.fx.fiatValue(amount) + ' ' + Daemon.fx.fiatCurrency + ')'
font.pixelSize: constants.fontSizeSmall
} }
} }

14
electrum/gui/qml/qetxfinalizer.py

@ -448,6 +448,7 @@ class QETxRbfFeeBumper(TxFeeSlider, TxMonMixin):
self._oldfee_rate = 0 self._oldfee_rate = 0
self._orig_tx = None self._orig_tx = None
self._rbf = True self._rbf = True
self._bump_method = 'preserve_payment'
oldfeeChanged = pyqtSignal() oldfeeChanged = pyqtSignal()
@pyqtProperty(QEAmount, notify=oldfeeChanged) @pyqtProperty(QEAmount, notify=oldfeeChanged)
@ -471,6 +472,18 @@ class QETxRbfFeeBumper(TxFeeSlider, TxMonMixin):
self._oldfee_rate = oldfeerate self._oldfee_rate = oldfeerate
self.oldfeeRateChanged.emit() self.oldfeeRateChanged.emit()
bumpMethodChanged = pyqtSignal()
@pyqtProperty(str, notify=bumpMethodChanged)
def bumpMethod(self):
return self._bump_method
@bumpMethod.setter
def bumpMethod(self, bumpmethod):
if self._bump_method != bumpmethod:
self._bump_method = bumpmethod
self.bumpMethodChanged.emit()
self.update()
def get_tx(self): def get_tx(self):
assert self._txid assert self._txid
@ -523,6 +536,7 @@ class QETxRbfFeeBumper(TxFeeSlider, TxMonMixin):
tx=self._orig_tx, tx=self._orig_tx,
txid=self._txid, txid=self._txid,
new_fee_rate=new_fee_rate, new_fee_rate=new_fee_rate,
decrease_payment=self._bump_method=='decrease_payment'
) )
except CannotBumpFee as e: except CannotBumpFee as e:
self._valid = False self._valid = False

Loading…
Cancel
Save