|
|
@ -14,9 +14,31 @@ class QETxDetails(QObject): |
|
|
|
|
|
|
|
_wallet = None |
|
|
|
_txid = None |
|
|
|
_label = '' |
|
|
|
|
|
|
|
_mempool_depth = None |
|
|
|
_date = None |
|
|
|
_status = '' |
|
|
|
_amount = QEAmount(amount_sat=0) |
|
|
|
_fee = QEAmount(amount_sat=0) |
|
|
|
_inputs = [] |
|
|
|
_outputs = [] |
|
|
|
|
|
|
|
_is_lightning_funding_tx = False |
|
|
|
_can_bump = False |
|
|
|
_can_dscancel = False |
|
|
|
_can_broadcast = False |
|
|
|
_can_cpfp = False |
|
|
|
_can_save_as_local = False |
|
|
|
_can_remove = False |
|
|
|
|
|
|
|
_is_mined = False |
|
|
|
|
|
|
|
_mempool_depth = '' |
|
|
|
|
|
|
|
_date = '' |
|
|
|
_height = 0 |
|
|
|
_confirmations = 0 |
|
|
|
_txpos = -1 |
|
|
|
_header_hash = '' |
|
|
|
|
|
|
|
detailsChanged = pyqtSignal() |
|
|
|
|
|
|
@ -60,18 +82,50 @@ class QETxDetails(QObject): |
|
|
|
def status(self): |
|
|
|
return self._status |
|
|
|
|
|
|
|
@pyqtProperty(str, notify=detailsChanged) |
|
|
|
def date(self): |
|
|
|
return self._date |
|
|
|
@pyqtProperty(QEAmount, notify=detailsChanged) |
|
|
|
def amount(self): |
|
|
|
return self._amount |
|
|
|
|
|
|
|
@pyqtProperty(str, notify=detailsChanged) |
|
|
|
def mempoolDepth(self): |
|
|
|
return self._mempool_depth |
|
|
|
@pyqtProperty(QEAmount, notify=detailsChanged) |
|
|
|
def fee(self): |
|
|
|
return self._fee |
|
|
|
|
|
|
|
@pyqtProperty('QVariantList', notify=detailsChanged) |
|
|
|
def inputs(self): |
|
|
|
return self._inputs |
|
|
|
|
|
|
|
@pyqtProperty('QVariantList', notify=detailsChanged) |
|
|
|
def outputs(self): |
|
|
|
return self._outputs |
|
|
|
|
|
|
|
@pyqtProperty(bool, notify=detailsChanged) |
|
|
|
def isMined(self): |
|
|
|
return self._is_mined |
|
|
|
|
|
|
|
@pyqtProperty(str, notify=detailsChanged) |
|
|
|
def mempoolDepth(self): |
|
|
|
return self._mempool_depth |
|
|
|
|
|
|
|
@pyqtProperty(str, notify=detailsChanged) |
|
|
|
def date(self): |
|
|
|
return self._date |
|
|
|
|
|
|
|
@pyqtProperty(int, notify=detailsChanged) |
|
|
|
def height(self): |
|
|
|
return self._height |
|
|
|
|
|
|
|
@pyqtProperty(int, notify=detailsChanged) |
|
|
|
def confirmations(self): |
|
|
|
return self._confirmations |
|
|
|
|
|
|
|
@pyqtProperty(int, notify=detailsChanged) |
|
|
|
def txpos(self): |
|
|
|
return self._txpos |
|
|
|
|
|
|
|
@pyqtProperty(str, notify=detailsChanged) |
|
|
|
def headerHash(self): |
|
|
|
return self._header_hash |
|
|
|
|
|
|
|
@pyqtProperty(bool, notify=detailsChanged) |
|
|
|
def isLightningFundingTx(self): |
|
|
|
return self._is_lightning_funding_tx |
|
|
@ -84,21 +138,21 @@ class QETxDetails(QObject): |
|
|
|
def canCancel(self): |
|
|
|
return self._can_dscancel |
|
|
|
|
|
|
|
@pyqtProperty(QEAmount, notify=detailsChanged) |
|
|
|
def amount(self): |
|
|
|
return self._amount |
|
|
|
@pyqtProperty(bool, notify=detailsChanged) |
|
|
|
def canBroadcast(self): |
|
|
|
return self._can_broadcast |
|
|
|
|
|
|
|
@pyqtProperty(QEAmount, notify=detailsChanged) |
|
|
|
def fee(self): |
|
|
|
return self._fee |
|
|
|
@pyqtProperty(bool, notify=detailsChanged) |
|
|
|
def canCpfp(self): |
|
|
|
return self._can_cpfp |
|
|
|
|
|
|
|
@pyqtProperty('QVariantList', notify=detailsChanged) |
|
|
|
def inputs(self): |
|
|
|
return self._inputs |
|
|
|
@pyqtProperty(bool, notify=detailsChanged) |
|
|
|
def canSaveAsLocal(self): |
|
|
|
return self._can_save_as_local |
|
|
|
|
|
|
|
@pyqtProperty('QVariantList', notify=detailsChanged) |
|
|
|
def outputs(self): |
|
|
|
return self._outputs |
|
|
|
@pyqtProperty(bool, notify=detailsChanged) |
|
|
|
def canRemove(self): |
|
|
|
return self._can_remove |
|
|
|
|
|
|
|
def update(self): |
|
|
|
if self._wallet is None: |
|
|
@ -108,6 +162,8 @@ class QETxDetails(QObject): |
|
|
|
# abusing get_input_tx to get tx from txid |
|
|
|
tx = self._wallet.wallet.get_input_tx(self._txid) |
|
|
|
|
|
|
|
#self._logger.debug(repr(tx.to_json())) |
|
|
|
|
|
|
|
self._inputs = list(map(lambda x: x.to_json(), tx.inputs())) |
|
|
|
self._outputs = list(map(lambda x: { |
|
|
|
'address': x.get_ui_address_str(), |
|
|
@ -116,26 +172,46 @@ class QETxDetails(QObject): |
|
|
|
}, tx.outputs())) |
|
|
|
|
|
|
|
txinfo = self._wallet.wallet.get_tx_info(tx) |
|
|
|
|
|
|
|
#self._logger.debug(repr(txinfo)) |
|
|
|
|
|
|
|
# can be None if outputs unrelated to wallet seed, |
|
|
|
# e.g. to_local local_force_close commitment CSV-locked p2wsh script |
|
|
|
if txinfo.amount is None: |
|
|
|
self._amount = QEAmount(amount_sat=0) |
|
|
|
else: |
|
|
|
self._amount = QEAmount(amount_sat=txinfo.amount) |
|
|
|
|
|
|
|
self._status = txinfo.status |
|
|
|
self._label = txinfo.label |
|
|
|
self._amount = QEAmount(amount_sat=txinfo.amount) # can be None? |
|
|
|
self._fee = QEAmount(amount_sat=txinfo.fee) |
|
|
|
|
|
|
|
self._is_mined = txinfo.tx_mined_status != None |
|
|
|
if self._is_mined: |
|
|
|
self._date = format_time(txinfo.tx_mined_status.timestamp) |
|
|
|
self.update_mined_status(txinfo.tx_mined_status) |
|
|
|
else: |
|
|
|
#TODO mempool_depth_bytes can be None? |
|
|
|
# TODO mempool_depth_bytes can be None if not mined? |
|
|
|
if txinfo.mempool_depth_bytes is None: |
|
|
|
self._logger.error('TX is not mined, yet mempool_depth_bytes is None') |
|
|
|
self._mempool_depth = self._wallet.wallet.config.depth_tooltip(txinfo.mempool_depth_bytes) |
|
|
|
|
|
|
|
self._is_lightning_funding_tx = txinfo.is_lightning_funding_tx |
|
|
|
self._can_bump = txinfo.can_bump |
|
|
|
self._can_dscancel = txinfo.can_dscancel |
|
|
|
|
|
|
|
self._logger.debug(repr(txinfo.mempool_depth_bytes)) |
|
|
|
self._logger.debug(repr(txinfo.can_broadcast)) |
|
|
|
self._logger.debug(repr(txinfo.can_cpfp)) |
|
|
|
self._logger.debug(repr(txinfo.can_save_as_local)) |
|
|
|
self._logger.debug(repr(txinfo.can_remove)) |
|
|
|
self._can_broadcast = txinfo.can_broadcast |
|
|
|
self._can_cpfp = txinfo.can_cpfp |
|
|
|
self._can_save_as_local = txinfo.can_save_as_local |
|
|
|
self._can_remove = txinfo.can_remove |
|
|
|
|
|
|
|
self.detailsChanged.emit() |
|
|
|
|
|
|
|
if self._label != txinfo.label: |
|
|
|
self._label = txinfo.label |
|
|
|
self.labelChanged.emit() |
|
|
|
|
|
|
|
def update_mined_status(self, tx_mined_info): |
|
|
|
self._mempool_depth = '' |
|
|
|
self._date = format_time(tx_mined_info.timestamp) |
|
|
|
self._height = tx_mined_info.height |
|
|
|
self._confirmations = tx_mined_info.conf |
|
|
|
self._txpos = tx_mined_info.txpos |
|
|
|
self._header_hash = tx_mined_info.header_hash |
|
|
|