Пример #1
0
    def export_transaction(self):
        path, _ = QtGui.QFileDialog.getSaveFileName(
            self, 'Export transaction', '', "bitshares transaction (*.json)")
        if not path:
            return False

        data = self.tx.json()
        if not ("operations" in data):
            data["operations"] = []
            for op in self.tx.ops:
                op_id = getOperationIdForClass(op.__class__.__name__)
                op_json = op.json()
                data["operations"].append([op_id, op_json])
        for k in ["missing_signatures", "signatures"]:
            try:
                if not (k in data):
                    data[k] = self.tx[k]
            except:
                pass

        data = json.dumps(data)

        with open(path, "w") as f:
            f.write(data)

        return True
Пример #2
0
    def _txRedraw(self):
        root = self.ui.txTable
        trx = self.trxbuffer
        iso = self.iso

        root.setRowCount(0)

        j = -1
        for op in trx.ops:
            op_id = getOperationIdForClass(op.__class__.__name__)
            op_json = op.json()
            fake_obj = {'op': [op_id, op_json], 'result': [0, True]}
            nextstatus = getOperationNameForId(op_id).upper()
            details = iso.historyDescription(fake_obj)
            description = details['long']

            j += 1
            root.insertRow(j)
            set_col(root, j, 0, nextstatus)
            set_col(root, j, 1, description)
Пример #3
0
    def applyTransaction(self, trx, iso):
        # NOTE: we must be very careful when asking trx[key],
        # the _get() method there is trigger-happy to call
        # constructTx() and loose our progress.
        root = self.ui.treeWidget

        core_fee = 0
        other_fees = {}

        root.clear()
        for op in trx.ops:
            op_id = getOperationIdForClass(op.__class__.__name__)
            op_json = op.json()
            fake_obj = {'op': [op_id, op_json], 'result': [0, True]}
            if 'fee' in op_json:
                fee = op_json['fee']
                fee_asset_id = fee['asset_id']
                if fee_asset_id == '1.3.0':  # Core Token
                    core_fee += fee['amount']
                else:
                    if not (fee_asset_id in other_fees):
                        other_fees[fee_asset_id] = 0
                    other_fees[fee_asset_id] += int(fee['amount'])

            nextstatus = getOperationNameForId(op_id).upper()
            details = iso.historyDescription(fake_obj)

            merge_in(root, op, nextstatus, details['long'], iso=iso)

        fee_text = ""
        if core_fee > 0:
            fee_text += str(iso.getAmount(core_fee, '1.3.0')) + "\n"
        for fee_asset_id, amount in other_fees.items():
            fee_amt = iso.getAmount(amount, fee_asset_id)
            fee_text += str(fee_amt) + "\n"
        self.ui.feeTotal.setPlainText(fee_text)

        icon_s = qicon(":/icons/images/signed.png")
        icon_u = qicon(":/icons/images/unsigned.png")

        table = self.ui.signatureTable
        table.clear()
        table.setRowCount(0)
        self.ui.signedCheckbox.setChecked(False)
        self.ui.broadcastButton.setEnabled(False)

        j = -1
        if "missing_signatures" in trx:
            for sig in trx['missing_signatures']:
                j += 1
                table.insertRow(j)
                table.setItem(j, 0, QTableWidgetItem("Missing: " + sig))
                table.item(j, 0).setIcon(icon_u)

        if "signatures" in trx:
            for sig in trx['signatures']:
                j += 1
                table.insertRow(j)
                table.setItem(j, 0, QTableWidgetItem(sig))
                table.item(j, 0).setIcon(icon_s)

        if "id" in trx:  # HACK -- this could be set by history window
            self.setWindowTitle("Transaction " + trx["id"])

        if trx._is_signed():
            self.ui.signedCheckbox.setChecked(True)
            self.ui.broadcastButton.setEnabled(True)