qml: apply TxInput/TxOutput coloring for swap and billing addresses.
This commit is contained in:
@@ -68,6 +68,7 @@ Item {
|
||||
property color colorAddressUsedWithBalance: Qt.rgba(0.75,0.75,0.75,1)
|
||||
property color colorAddressFrozen: Qt.rgba(0.5,0.5,1,1)
|
||||
property color colorAddressBilling: "#8cb3f2"
|
||||
property color colorAddressSwap: colorAddressBilling
|
||||
|
||||
function colorAlpha(baseColor, alpha) {
|
||||
return Qt.rgba(baseColor.r, baseColor.g, baseColor.b, alpha)
|
||||
|
||||
@@ -11,6 +11,12 @@ TextHighlightPane {
|
||||
property variant model
|
||||
property int idx: -1
|
||||
|
||||
property string _suffix: model.is_mine || model.is_change
|
||||
? qsTr('mine')
|
||||
: model.is_swap
|
||||
? qsTr('swap')
|
||||
: ""
|
||||
|
||||
ColumnLayout {
|
||||
width: parent.width
|
||||
|
||||
@@ -55,16 +61,21 @@ TextHighlightPane {
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: model.address
|
||||
? model.address
|
||||
? model.address + (_suffix
|
||||
? ' <span style="font-size:' + constants.fontSizeXSmall + 'px">(' + _suffix + ')</span>'
|
||||
: "")
|
||||
: '<' + qsTr('address unknown') + '>'
|
||||
font.family: FixedFont
|
||||
font.pixelSize: constants.fontSizeMedium
|
||||
textFormat: Text.RichText
|
||||
color: model.is_mine
|
||||
? model.is_change
|
||||
? constants.colorAddressInternal
|
||||
: constants.colorAddressExternal
|
||||
: Material.foreground
|
||||
elide: Text.ElideMiddle
|
||||
: model.is_swap
|
||||
? constants.colorAddressSwap
|
||||
: Material.foreground
|
||||
wrapMode: Text.WrapAnywhere
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,14 @@ TextHighlightPane {
|
||||
property bool allowClickAddress: true
|
||||
property int idx: -1
|
||||
|
||||
property string _suffix: model.is_mine || model.is_change
|
||||
? qsTr('mine')
|
||||
: model.is_swap
|
||||
? qsTr('swap')
|
||||
: model.is_billing
|
||||
? qsTr('billing')
|
||||
: ""
|
||||
|
||||
RowLayout {
|
||||
width: parent.width
|
||||
|
||||
@@ -57,18 +65,23 @@ TextHighlightPane {
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Label {
|
||||
text: model.address
|
||||
text: model.address + (_suffix
|
||||
? ' <span style="font-size:' + constants.fontSizeXSmall + 'px">(' + _suffix + ')</span>'
|
||||
: "")
|
||||
Layout.fillWidth: true
|
||||
wrapMode: Text.Wrap
|
||||
font.pixelSize: constants.fontSizeMedium
|
||||
font.family: FixedFont
|
||||
textFormat: Text.RichText
|
||||
color: model.is_mine
|
||||
? model.is_change
|
||||
? constants.colorAddressInternal
|
||||
: constants.colorAddressExternal
|
||||
: model.is_billing
|
||||
? constants.colorAddressBilling
|
||||
: Material.foreground
|
||||
: model.is_swap
|
||||
? constants.colorAddressSwap
|
||||
: Material.foreground
|
||||
TapHandler {
|
||||
enabled: allowClickAddress && model.is_mine
|
||||
onTapped: {
|
||||
|
||||
@@ -4,6 +4,7 @@ from PyQt6.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
||||
|
||||
from electrum.i18n import _
|
||||
from electrum.logging import get_logger
|
||||
from electrum.bitcoin import DummyAddress
|
||||
from electrum.util import format_time, TxMinedInfo
|
||||
from electrum.transaction import tx_from_any, Transaction, PartialTxInput, Sighash, PartialTransaction, TxOutpoint
|
||||
from electrum.network import Network
|
||||
@@ -277,12 +278,15 @@ class QETxDetails(QObject, QtEventListener):
|
||||
Network.run_from_another_thread(
|
||||
self._tx.add_info_from_network(self._wallet.wallet.network, timeout=10)) # FIXME is this needed?...
|
||||
|
||||
sm = self._wallet.wallet.lnworker.swap_manager if self._wallet.wallet.lnworker else None
|
||||
|
||||
self._inputs = list(map(lambda x: {
|
||||
'short_id': x.prevout.short_name(),
|
||||
'value': x.value_sats(),
|
||||
'address': x.address,
|
||||
'is_mine': self._wallet.wallet.is_mine(x.address),
|
||||
'is_change': self._wallet.wallet.is_change(x.address)
|
||||
'is_change': self._wallet.wallet.is_change(x.address),
|
||||
'is_swap': False if not sm else sm.is_lockup_address_for_a_swap(x.address) or x.address == DummyAddress.SWAP
|
||||
}, self._tx.inputs()))
|
||||
self._outputs = list(map(lambda x: {
|
||||
'address': x.get_ui_address_str(),
|
||||
@@ -290,7 +294,8 @@ class QETxDetails(QObject, QtEventListener):
|
||||
'short_id': '', # TODO
|
||||
'is_mine': self._wallet.wallet.is_mine(x.get_ui_address_str()),
|
||||
'is_change': self._wallet.wallet.is_change(x.get_ui_address_str()),
|
||||
'is_billing': self._wallet.wallet.is_billing_address(x.get_ui_address_str())
|
||||
'is_billing': self._wallet.wallet.is_billing_address(x.get_ui_address_str()),
|
||||
'is_swap': False if not sm else sm.is_lockup_address_for_a_swap(x.get_ui_address_str()) or x.get_ui_address_str() == DummyAddress.SWAP
|
||||
}, self._tx.outputs()))
|
||||
|
||||
txinfo = self._wallet.wallet.get_tx_info(self._tx)
|
||||
|
||||
@@ -8,6 +8,7 @@ from PyQt6.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
||||
|
||||
from electrum.logging import get_logger
|
||||
from electrum.i18n import _
|
||||
from electrum.bitcoin import DummyAddress
|
||||
from electrum.transaction import PartialTxOutput, PartialTransaction, Transaction, TxOutpoint
|
||||
from electrum.util import NotEnoughFunds, profiler, quantize_feerate, UserFacingException
|
||||
from electrum.wallet import CannotBumpFee, CannotDoubleSpendTx, CannotCPFP, BumpFeeStrategy, sweep_preparations
|
||||
@@ -235,13 +236,11 @@ class TxFeeSlider(FeeSlider):
|
||||
def update_inputs_from_tx(self, tx):
|
||||
inputs = []
|
||||
for inp in tx.inputs():
|
||||
# addr
|
||||
# addr = self.wallet.adb.get_txin_address(txin)
|
||||
addr = inp.address
|
||||
address_str = '<address unknown>' if addr is None else addr
|
||||
|
||||
txin_value = inp.value_sats() if inp.value_sats() else 0
|
||||
#self.wallet.adb.get_txin_value(txin)
|
||||
|
||||
inputs.append({
|
||||
'address': address_str,
|
||||
@@ -250,11 +249,14 @@ class TxFeeSlider(FeeSlider):
|
||||
'is_coinbase': inp.is_coinbase_input(),
|
||||
'is_mine': self._wallet.wallet.is_mine(addr),
|
||||
'is_change': self._wallet.wallet.is_change(addr),
|
||||
'prevout_txid': inp.prevout.txid.hex()
|
||||
'prevout_txid': inp.prevout.txid.hex(),
|
||||
'is_swap': False
|
||||
})
|
||||
self.inputs = inputs
|
||||
|
||||
def update_outputs_from_tx(self, tx):
|
||||
sm = self._wallet.wallet.lnworker.swap_manager if self._wallet.wallet.lnworker else None
|
||||
|
||||
outputs = []
|
||||
for idx, o in enumerate(tx.outputs()):
|
||||
outputs.append({
|
||||
@@ -263,7 +265,8 @@ class TxFeeSlider(FeeSlider):
|
||||
'short_id': str(TxOutpoint(bytes.fromhex(tx.txid()), idx).short_name()) if tx.txid() else '',
|
||||
'is_mine': self._wallet.wallet.is_mine(o.get_ui_address_str()),
|
||||
'is_change': self._wallet.wallet.is_change(o.get_ui_address_str()),
|
||||
'is_billing': self._wallet.wallet.is_billing_address(o.get_ui_address_str())
|
||||
'is_billing': self._wallet.wallet.is_billing_address(o.get_ui_address_str()),
|
||||
'is_swap': False if not sm else sm.is_lockup_address_for_a_swap(o.get_ui_address_str()) or o.get_ui_address_str() == DummyAddress.SWAP
|
||||
})
|
||||
self.outputs = outputs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user