Example #1
0
    def showTransaction_desc_(self, txraw, desc) -> None:
        tx = Transaction(txraw)
        tx.deserialize()
        tx_hash, status_, label_, can_broadcast, can_bump, amount, fee, height, conf, timestamp, exp_n = wallet(
        ).get_tx_info(tx)
        # print("send: status_",status_,"label_",label_,"amount",amount,"conf",conf)
        size = tx.estimated_size()
        conf = 0 if conf is None else conf
        timestamp = time.time() if timestamp is None else timestamp
        status, status_str = (
            status_, _("Unsigned")
        )  # wallet().get_tx_status(tx_hash, height, conf, timestamp)
        doFX = fx() and fx().is_enabled()
        ccy = fx().get_currency() if doFX else None
        fiat_amount_str = str(self.fiat.text) if doFX else None
        # HistoryEntry = namedtuple("HistoryEntry", "tx tx_hash status_str label v_str balance_str date ts conf status value fiat_amount fiat_balance fiat_amount_str fiat_balance_str ccy status_image")
        entry = HistoryEntry(
            tx, tx_hash, status_str, str(desc), self.amt.text, "",
            timestamp_to_datetime(time.time() if conf <= 0 else timestamp),
            timestamp, conf, status, amount, None, None, fiat_amount_str, None,
            ccy, None)

        def newLabel(l):
            self.descDel.text = l

        self.navigationController.pushViewController_animated_(
            txdetail.CreateTxDetailWithEntry(entry, on_label=newLabel), True)

        # For modal do the following:
        # self.presentViewController_animated_completion_(txdetail.CreateTxDetailWithEntry(entry, on_label = newLabel, asModalNav = True), True, None)
        '''
Example #2
0
def CreateTxDetailWithTx(tx: Transaction,
                         on_label=None,
                         on_appear=None,
                         asModalNav=False) -> ObjCInstance:
    parent = gui.ElectrumGui.gui
    wallet = parent.wallet
    import time

    tx_hash, status_, label_, can_broadcast, can_bump, amount, fee, height, conf, timestamp, exp_n = wallet.get_tx_info(
        tx)
    size = tx.estimated_size()
    status_str = ""
    status = status_
    img = None
    if conf is not None:
        if tx_hash is not None and height is not None and timestamp is not None:
            status, status_str = wallet.get_tx_status(tx_hash, height, conf,
                                                      timestamp)
            if status is not None and status >= 0 and status < len(
                    StatusImages):
                img = StatusImages[status]
    else:
        conf = 0
    timestamp = time.time() if timestamp is None else timestamp
    doFX = False  # fx() and fx().is_enabled()
    ccy = None  # fx().get_currency() if doFX else None
    fiat_amount_str = None  # str(self.fiat.text) if doFX else None
    # HistoryEntry = namedtuple("HistoryEntry", "extra_data tx_hash status_str label v_str balance_str date ts conf status value fiat_amount fiat_balance fiat_amount_str fiat_balance_str ccy status_image")
    entry = HistoryEntry(
        tx, tx_hash, status_str, label_,
        parent.format_amount(amount) if amount is not None else
        _("Transaction unrelated to your wallet"), "",
        timestamp_to_datetime(time.time() if conf <= 0 else timestamp),
        timestamp, conf, status, amount, None, None, fiat_amount_str, None,
        ccy, img)

    return CreateTxDetailWithEntry(entry,
                                   on_label=on_label,
                                   on_appear=on_appear,
                                   asModalNav=asModalNav)