|
|
|
@ -152,7 +152,7 @@ class TxInOutWidget(QWidget): |
|
|
|
lnk.setAnchor(True) |
|
|
|
lnk.setAnchor(True) |
|
|
|
lnk.setUnderlineStyle(QTextCharFormat.SingleUnderline) |
|
|
|
lnk.setUnderlineStyle(QTextCharFormat.SingleUnderline) |
|
|
|
tf_used_recv, tf_used_change, tf_used_2fa = False, False, False |
|
|
|
tf_used_recv, tf_used_change, tf_used_2fa = False, False, False |
|
|
|
def addr_text_format(addr): |
|
|
|
def addr_text_format(addr: str) -> QTextCharFormat: |
|
|
|
nonlocal tf_used_recv, tf_used_change, tf_used_2fa |
|
|
|
nonlocal tf_used_recv, tf_used_change, tf_used_2fa |
|
|
|
if self.wallet.is_mine(addr): |
|
|
|
if self.wallet.is_mine(addr): |
|
|
|
if self.wallet.is_change(addr): |
|
|
|
if self.wallet.is_change(addr): |
|
|
|
@ -171,29 +171,29 @@ class TxInOutWidget(QWidget): |
|
|
|
return self.txo_color_2fa.text_char_format |
|
|
|
return self.txo_color_2fa.text_char_format |
|
|
|
return ext |
|
|
|
return ext |
|
|
|
|
|
|
|
|
|
|
|
i_text = self.inputs_textedit |
|
|
|
def insert_tx_io( |
|
|
|
i_text.clear() |
|
|
|
*, |
|
|
|
i_text.setFont(QFont(MONOSPACE_FONT)) |
|
|
|
cursor: QCursor, |
|
|
|
i_text.setReadOnly(True) |
|
|
|
txio_idx: int, |
|
|
|
cursor = i_text.textCursor() |
|
|
|
is_coinbase: bool, |
|
|
|
for txin_idx, txin in enumerate(self.tx.inputs()): |
|
|
|
tcf_shortid: QTextCharFormat = None, |
|
|
|
addr = self.wallet.adb.get_txin_address(txin) |
|
|
|
short_id: str, |
|
|
|
txin_value = self.wallet.adb.get_txin_value(txin) |
|
|
|
addr: Optional[str], |
|
|
|
# prepare text char formats |
|
|
|
value: Optional[int], |
|
|
|
a_name = f"input {txin_idx}" |
|
|
|
): |
|
|
|
tcf_ext = QTextCharFormat(ext) |
|
|
|
tcf_ext = QTextCharFormat(ext) |
|
|
|
tcf_shortid = QTextCharFormat(lnk) |
|
|
|
|
|
|
|
tcf_shortid.setAnchorHref(txin.prevout.txid.hex()) |
|
|
|
|
|
|
|
tcf_addr = addr_text_format(addr) |
|
|
|
tcf_addr = addr_text_format(addr) |
|
|
|
|
|
|
|
if tcf_shortid is None: |
|
|
|
|
|
|
|
tcf_shortid = tcf_ext |
|
|
|
|
|
|
|
a_name = f"txio_idx {txio_idx}" |
|
|
|
for tcf in (tcf_ext, tcf_shortid, tcf_addr): # used by context menu creation |
|
|
|
for tcf in (tcf_ext, tcf_shortid, tcf_addr): # used by context menu creation |
|
|
|
tcf.setAnchorNames([a_name]) |
|
|
|
tcf.setAnchorNames([a_name]) |
|
|
|
# insert text |
|
|
|
if is_coinbase: |
|
|
|
if txin.is_coinbase_input(): |
|
|
|
|
|
|
|
cursor.insertText('coinbase', tcf_ext) |
|
|
|
cursor.insertText('coinbase', tcf_ext) |
|
|
|
else: |
|
|
|
else: |
|
|
|
# short_id |
|
|
|
# short_id |
|
|
|
cursor.insertText(str(txin.short_id), tcf_shortid) |
|
|
|
cursor.insertText(short_id, tcf_shortid) |
|
|
|
cursor.insertText(" " * max(0, 15 - len(str(txin.short_id))), tcf_ext) # padding |
|
|
|
cursor.insertText(" " * max(0, 15 - len(short_id)), tcf_ext) # padding |
|
|
|
cursor.insertText('\t', tcf_ext) |
|
|
|
cursor.insertText('\t', tcf_ext) |
|
|
|
# addr |
|
|
|
# addr |
|
|
|
address_str = addr or '<address unknown>' |
|
|
|
address_str = addr or '<address unknown>' |
|
|
|
@ -201,10 +201,26 @@ class TxInOutWidget(QWidget): |
|
|
|
cursor.insertText(" " * max(0, 62 - len(address_str)), tcf_ext) # padding |
|
|
|
cursor.insertText(" " * max(0, 62 - len(address_str)), tcf_ext) # padding |
|
|
|
cursor.insertText('\t', tcf_ext) |
|
|
|
cursor.insertText('\t', tcf_ext) |
|
|
|
# value |
|
|
|
# value |
|
|
|
value_str = self.main_window.format_amount(txin_value, whitespaces=True) |
|
|
|
value_str = self.main_window.format_amount(value, whitespaces=True) |
|
|
|
cursor.insertText(value_str, tcf_ext) |
|
|
|
cursor.insertText(value_str, tcf_ext) |
|
|
|
cursor.insertBlock() |
|
|
|
cursor.insertBlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
i_text = self.inputs_textedit |
|
|
|
|
|
|
|
i_text.clear() |
|
|
|
|
|
|
|
i_text.setFont(QFont(MONOSPACE_FONT)) |
|
|
|
|
|
|
|
i_text.setReadOnly(True) |
|
|
|
|
|
|
|
cursor = i_text.textCursor() |
|
|
|
|
|
|
|
for txin_idx, txin in enumerate(self.tx.inputs()): |
|
|
|
|
|
|
|
addr = self.wallet.adb.get_txin_address(txin) |
|
|
|
|
|
|
|
txin_value = self.wallet.adb.get_txin_value(txin) |
|
|
|
|
|
|
|
tcf_shortid = QTextCharFormat(lnk) |
|
|
|
|
|
|
|
tcf_shortid.setAnchorHref(txin.prevout.txid.hex()) |
|
|
|
|
|
|
|
insert_tx_io( |
|
|
|
|
|
|
|
cursor=cursor, is_coinbase=txin.is_coinbase_input(), txio_idx=txin_idx, |
|
|
|
|
|
|
|
tcf_shortid=tcf_shortid, |
|
|
|
|
|
|
|
short_id=str(txin.short_id), addr=addr, value=txin_value, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
self.outputs_header.setText(_("Outputs") + ' (%d)'%len(self.tx.outputs())) |
|
|
|
self.outputs_header.setText(_("Outputs") + ' (%d)'%len(self.tx.outputs())) |
|
|
|
o_text = self.outputs_textedit |
|
|
|
o_text = self.outputs_textedit |
|
|
|
o_text.clear() |
|
|
|
o_text.clear() |
|
|
|
@ -218,26 +234,11 @@ class TxInOutWidget(QWidget): |
|
|
|
short_id = ShortID.from_components(tx_height, tx_pos, txout_idx) |
|
|
|
short_id = ShortID.from_components(tx_height, tx_pos, txout_idx) |
|
|
|
else: |
|
|
|
else: |
|
|
|
short_id = TxOutpoint(tx_hash, txout_idx).short_name() |
|
|
|
short_id = TxOutpoint(tx_hash, txout_idx).short_name() |
|
|
|
addr, value = o.get_ui_address_str(), o.value |
|
|
|
addr = o.get_ui_address_str() |
|
|
|
# prepare text char formats |
|
|
|
insert_tx_io( |
|
|
|
a_name = f"output {txout_idx}" |
|
|
|
cursor=cursor, is_coinbase=False, txio_idx=txout_idx, |
|
|
|
tcf_ext = QTextCharFormat(ext) |
|
|
|
short_id=str(short_id), addr=addr, value=o.value, |
|
|
|
tcf_addr = addr_text_format(addr) |
|
|
|
) |
|
|
|
for tcf in (tcf_ext, tcf_addr): # used by context menu creation |
|
|
|
|
|
|
|
tcf.setAnchorNames([a_name]) |
|
|
|
|
|
|
|
# short id |
|
|
|
|
|
|
|
cursor.insertText(str(short_id), tcf_ext) |
|
|
|
|
|
|
|
cursor.insertText(" " * max(0, 15 - len(str(short_id))), tcf_ext) # padding |
|
|
|
|
|
|
|
cursor.insertText('\t', tcf_ext) |
|
|
|
|
|
|
|
# addr |
|
|
|
|
|
|
|
address_str = addr or '<address unknown>' |
|
|
|
|
|
|
|
cursor.insertText(address_str, tcf_addr) |
|
|
|
|
|
|
|
cursor.insertText(" " * max(0, 62 - len(address_str)), tcf_ext) # padding |
|
|
|
|
|
|
|
cursor.insertText('\t', tcf_ext) |
|
|
|
|
|
|
|
# value |
|
|
|
|
|
|
|
value_str = self.main_window.format_amount(value, whitespaces=True) |
|
|
|
|
|
|
|
cursor.insertText(value_str, tcf_ext) |
|
|
|
|
|
|
|
cursor.insertBlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.txo_color_recv.legend_label.setVisible(tf_used_recv) |
|
|
|
self.txo_color_recv.legend_label.setVisible(tf_used_recv) |
|
|
|
self.txo_color_change.legend_label.setVisible(tf_used_change) |
|
|
|
self.txo_color_change.legend_label.setVisible(tf_used_change) |
|
|
|
@ -272,8 +273,8 @@ class TxInOutWidget(QWidget): |
|
|
|
menu = QMenu() |
|
|
|
menu = QMenu() |
|
|
|
show_list = [] |
|
|
|
show_list = [] |
|
|
|
copy_list = [] |
|
|
|
copy_list = [] |
|
|
|
# figure out which input they right-clicked on. input lines have an anchor named "input N" |
|
|
|
# figure out which input they right-clicked on. input lines have an anchor named "txio_idx N" |
|
|
|
txin_idx = int(name.split()[1]) # split "input N", translate N -> int |
|
|
|
txin_idx = int(name.split()[1]) # split "txio_idx N", translate N -> int |
|
|
|
txin = self.tx.inputs()[txin_idx] |
|
|
|
txin = self.tx.inputs()[txin_idx] |
|
|
|
|
|
|
|
|
|
|
|
menu.addAction(f"Tx Input #{txin_idx}").setDisabled(True) |
|
|
|
menu.addAction(f"Tx Input #{txin_idx}").setDisabled(True) |
|
|
|
@ -320,8 +321,8 @@ class TxInOutWidget(QWidget): |
|
|
|
menu = QMenu() |
|
|
|
menu = QMenu() |
|
|
|
show_list = [] |
|
|
|
show_list = [] |
|
|
|
copy_list = [] |
|
|
|
copy_list = [] |
|
|
|
# figure out which output they right-clicked on. output lines have an anchor named "output N" |
|
|
|
# figure out which output they right-clicked on. output lines have an anchor named "txio_idx N" |
|
|
|
txout_idx = int(name.split()[1]) # split "output N", translate N -> int |
|
|
|
txout_idx = int(name.split()[1]) # split "txio_idx N", translate N -> int |
|
|
|
menu.addAction(f"Tx Output #{txout_idx}").setDisabled(True) |
|
|
|
menu.addAction(f"Tx Output #{txout_idx}").setDisabled(True) |
|
|
|
menu.addSeparator() |
|
|
|
menu.addSeparator() |
|
|
|
if addr := self.tx.outputs()[txout_idx].address: |
|
|
|
if addr := self.tx.outputs()[txout_idx].address: |
|
|
|
|