Example #1
0
 def __init__(self, parent=None):
     super(LockTimeWidget, self).__init__(parent)
     self.locktime_raw = QLineEdit()
     self.locktime_human = QLineEdit()
     for i in [self.locktime_raw, self.locktime_human]:
         i.setReadOnly(True)
     hbox = HBox(self.locktime_raw, self.locktime_human)
     hbox.setContentsMargins(0, 0, 0, 0)
     self.setLayout(hbox)
Example #2
0
 def __init__(self, parent=None):
     super(LockTimeWidget, self).__init__(parent)
     self.locktime_raw = QLineEdit()
     self.locktime_human = QLineEdit()
     for i in [self.locktime_raw, self.locktime_human]:
         i.setReadOnly(True)
     hbox = HBox(self.locktime_raw, self.locktime_human)
     hbox.setContentsMargins(0, 0, 0, 0)
     self.setLayout(hbox)
Example #3
0
 def __init__(self, parent=None):
     super(TimestampWidget, self).__init__(parent)
     self.timestamp_raw = QLineEdit()
     self.timestamp_human = QLineEdit()
     for i in [self.timestamp_raw, self.timestamp_human]:
         i.setReadOnly(True)
     hbox = HBox(self.timestamp_raw, self.timestamp_human)
     hbox.setContentsMargins(0, 0, 0, 0)
     self.setLayout(hbox)
     self.timestamp_raw.textChanged.connect(self.update_time)
Example #4
0
 def __init__(self, parent=None):
     super(TimestampWidget, self).__init__(parent)
     self.timestamp_raw = QLineEdit()
     self.timestamp_human = QLineEdit()
     for i in [self.timestamp_raw, self.timestamp_human]:
         i.setReadOnly(True)
     hbox = HBox(self.timestamp_raw, self.timestamp_human)
     hbox.setContentsMargins(0, 0, 0, 0)
     self.setLayout(hbox)
     self.timestamp_raw.textChanged.connect(self.update_time)
Example #5
0
    def create_layout(self):
        form = QFormLayout()

        self.model = VarsModel(self.data)

        self.view = QTableView()
        self.view.setModel(self.model)
        self.view.horizontalHeader().setResizeMode(1, QHeaderView.Stretch)
        self.view.horizontalHeader().setHighlightSections(False)
        self.view.verticalHeader().setDefaultSectionSize(22)
        self.view.verticalHeader().setVisible(False)
        self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.context_menu)
        self.view.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding))
        self.view.setSelectionMode(QAbstractItemView.SingleSelection)
        self.view.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.view.setAlternatingRowColors(True)

        self.filter_combo = QComboBox()
        self.filter_combo.addItems(self.filters)
        self.filter_combo.currentIndexChanged.connect(self.filter_table)

        form.addRow('Filter:', self.filter_combo)
        form.addRow(self.view)

        # Controls for adding/removing variables

        self.new_var_key = QLineEdit()
        self.setFocusProxy(self.new_var_key)
        self.new_var_value = QLineEdit()
        add_var_btn = QPushButton('Set')
        add_var_btn.clicked.connect(self.add_new_var)
        add_var_hbox = HBox(self.new_var_key, QLabel(':'), self.new_var_value, add_var_btn)

        self.del_var_key = QLineEdit()
        del_var_button = QPushButton('Delete')
        del_var_button.clicked.connect(self.remove_var)
        del_var_hbox = HBox(self.del_var_key, del_var_button)

        self.auto_save_check = QCheckBox('Automatically save')
        self.auto_save_check.setChecked(self.auto_save)
        def change_auto_save(is_checked):
            is_checked = True if is_checked else False
            self.auto_save = is_checked
            self.set_option('auto_save', self.auto_save)
        self.auto_save_check.stateChanged.connect(change_auto_save)
        self.save_button = QPushButton('Save')
        self.save_button.clicked.connect(self.save_variables)
        self.save_button.setToolTip('Save variables to config file')

        form.addRow('Add:', add_var_hbox)
        form.addRow('Delete:', del_var_hbox)
        form.addRow(floated_buttons([self.auto_save_check, self.save_button]))
        return form
Example #6
0
    def create_main_tab(self):
        self.execution_widget = ScriptExecutionWidget(self.execution)
        # For variable substitution
        self.execution_widget.model.plugin_handler = self.handler

        self.execution_delegate = ScriptExecutionDelegate()
        self.execution_widget.view.setItemDelegate(self.execution_delegate)

        # Raw script input.
        self.tx_script = QPlainTextEdit()
        self.tx_script.setWhatsThis('Enter a raw script here to evaluate it.')
        self.tx_script.setFont(monospace_font)
        self.tx_script.setTabChangesFocus(True)

        self.clear_button = QPushButton('Clear')
        self.clear_button.setToolTip('Clear the current script.')
        self.clear_button.clicked.connect(self.reset)
        self.do_button = QPushButton('&Evaluate')
        self.do_button.setToolTip('Evaluate the entire script.')
        self.do_button.clicked.connect(self.do_evaluate)
        btn_hbox = floated_buttons([self.clear_button, self.do_button], left=True)

        vbox = QVBoxLayout()
        vbox.addWidget(QLabel('Script:'))
        vbox.addWidget(self.tx_script)
        vbox.addLayout(btn_hbox)
        vbox.addWidget(self.execution_widget, stretch=1)

        self.next_button = QPushButton('Next')
        self.next_button.setToolTip('Step forward in script execution.')
        self.next_button.clicked.connect(self.execution_widget.select_next)
        self.prev_button = QPushButton('Previous')
        self.prev_button.setToolTip('Step backward in script execution.')
        self.prev_button.clicked.connect(self.execution_widget.select_prev)

        controls_hbox = floated_buttons([self.prev_button, self.next_button], left=True)
        vbox.addLayout(controls_hbox)

        self.script_passed = ReadOnlyCheckBox('Passed')
        self.script_passed.setToolTip('Whether the script passed')
        self.script_passed.setWhatsThis('This box is checked if the script finished with a nonzero top stack value.')
        self.script_verified = ReadOnlyCheckBox('Verified')
        self.script_verified.setToolTip('Whether the script was verified with an input script')
        self.script_verified.setWhatsThis('This box is checked if the script was verified with a transaction\'s input script.')
        pass_hbox = HBox(QLabel('Script: '), self.script_passed, self.script_verified)
        pass_hbox.addStretch(1)
        vbox.addLayout(pass_hbox)

        w = QWidget()
        w.setLayout(vbox)
        return w
Example #7
0
    def __init__(self, parent=None):
        super(TxProperties, self).__init__(parent)
        self.tx_size_edit = QLineEdit()
        self.tx_size_edit.setReadOnly(True)
        tx_size = HBox(QLabel('Size:'), self.tx_size_edit)
        tx_size.setContentsMargins(0, 0, 0, 0)
        self.tx_size = QWidget()
        self.tx_size.setLayout(tx_size)
        self.tx_size.setToolTip('Size (in bytes) of the serialized tx')

        self.is_final = ReadOnlyCheckBox('Is Final')
        self.is_final.setToolTip('True if all inputs have a Sequence of 0xffffffff')
        self.is_coinbase = ReadOnlyCheckBox('Is Coinbase')
        self.is_coinbase.setToolTip('True if the tx generates new coins via mining')
        hbox = floated_buttons([self.tx_size, self.is_final, self.is_coinbase], left=True)
        hbox.setContentsMargins(16, 0, 0, 0)
        self.setLayout(hbox)
Example #8
0
    def __init__(self, parent=None):
        super(TxProperties, self).__init__(parent)
        self.tx_size_edit = QLineEdit()
        self.tx_size_edit.setReadOnly(True)
        tx_size = HBox(QLabel('Size:'), self.tx_size_edit)
        tx_size.setContentsMargins(0, 0, 0, 0)
        self.tx_size = QWidget()
        self.tx_size.setLayout(tx_size)
        self.tx_size.setToolTip('Size (in bytes) of the serialized tx')

        self.is_final = ReadOnlyCheckBox('Is Final')
        self.is_final.setToolTip(
            'True if all inputs have a Sequence of 0xffffffff')
        self.is_coinbase = ReadOnlyCheckBox('Is Coinbase')
        self.is_coinbase.setToolTip(
            'True if the tx generates new coins via mining')
        hbox = floated_buttons([self.tx_size, self.is_final, self.is_coinbase],
                               left=True)
        hbox.setContentsMargins(16, 0, 0, 0)
        self.setLayout(hbox)
Example #9
0
    def __init__(self, main_window, tree, parent=None):
        super(InputsEditor, self).__init__(tree, parent)
        self.prev_tx = QLineEdit()
        self.prev_tx.setToolTip('Transaction ID of the tx with the output being spent')

        self.prev_vout = AmountEdit()
        self.prev_vout.setToolTip('Output index of the previous transaction')

        self.script = ScriptEditor(main_window)
        self.script.setToolTip('Script that will be put on the stack before the previous output\'s script.')

        self.sequence = AmountEdit()
        self.sequence.setText('4294967295')
        maxify_input_sequence = QPushButton('Max')
        maxify_input_sequence.clicked.connect(lambda: self.sequence.setText('0xffffffff'))

        for i in [self.prev_tx, self.prev_vout, self.script, self.sequence]:
            i.setFont(monospace_font)

        self.mapper.addMapping(self.prev_tx, 0)
        self.mapper.addMapping(self.prev_vout, 1, 'amount')
        self.mapper.addMapping(self.script, 2, 'humanText')
        self.mapper.addMapping(self.sequence, 3, 'amount')

        delete_button = QPushButton('Remove Input')
        delete_button.setToolTip('Remove this input from the transaction')
        delete_button.clicked.connect(self.do_delete)
        submit_button = QPushButton('Save')
        submit_button.setToolTip('Update input with the above data')
        submit_button.clicked.connect(self.do_submit)

        form = QFormLayout()
        form.setContentsMargins(0, 0, 0, 0)
        form.addRow('Previous Transaction: ', self.prev_tx)
        form.addRow('Previous Tx Output: ', self.prev_vout)
        form.addRow('Input script: ', self.script)
        seq_desc = QLabel('Sequence is mostly deprecated.\nIf an input has a sequence that\'s not the maximum value, the transaction\'s locktime will apply.')
        seq_desc.setWordWrap(True)
        form.addRow(seq_desc)
        form.addRow('Sequence: ', HBox(self.sequence, maxify_input_sequence))
        form.addRow(floated_buttons([delete_button, submit_button]))

        self.setLayout(form)
Example #10
0
    def create_layout(self):
        form = QFormLayout()

        self.model = VarsModel(self.data)
        self.proxy_model = VarsProxyModel()
        self.proxy_model.setSourceModel(self.model)

        self.view = QTableView()
        self.view.setWhatsThis(
            'This table displays the variables you have defined.')
        self.view.setModel(self.proxy_model)
        self.view.setSortingEnabled(True)
        self.view.sortByColumn(0, QtCore.Qt.AscendingOrder)
        self.view.horizontalHeader().setResizeMode(1, QHeaderView.Stretch)
        self.view.horizontalHeader().setHighlightSections(False)
        self.view.verticalHeader().setDefaultSectionSize(22)
        self.view.verticalHeader().setVisible(False)
        self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.context_menu)
        self.view.setSizePolicy(
            QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding))
        self.view.setSelectionMode(QAbstractItemView.SingleSelection)
        self.view.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.view.setAlternatingRowColors(True)

        form.addRow(self.create_filters_box())
        form.addRow(self.view)

        # Controls for adding/removing variables

        self.new_var_key = QLineEdit()
        self.new_var_key.setPlaceholderText('Key')
        self.new_var_key.setWhatsThis(
            'Enter the name to give the new variable here.')
        self.setFocusProxy(self.new_var_key)
        self.new_var_value = QLineEdit()
        self.new_var_value.setPlaceholderText('Value')
        self.new_var_value.setWhatsThis(
            'Enter the value to give the new variable here.')
        add_var_btn = QPushButton('&Add')
        add_var_btn.clicked.connect(self.add_new_var)
        add_var_hbox = HBox(self.new_var_key, QLabel(':'), self.new_var_value,
                            add_var_btn)

        self.auto_save_check = QCheckBox('Automatically save')
        self.auto_save_check.setWhatsThis(
            'If this box is checked, then your stored variables will automatically be saved whenever one is added or deleted.'
        )
        self.auto_save_check.setChecked(self.auto_save)

        def change_auto_save(is_checked):
            is_checked = True if is_checked else False
            self.auto_save = is_checked
            self.set_option('auto_save', self.auto_save)

        self.auto_save_check.stateChanged.connect(change_auto_save)
        self.save_button = QPushButton('Save')
        self.save_button.clicked.connect(self.save_variables)
        self.save_button.setToolTip('Save variables to config file')
        self.save_button.setWhatsThis(
            'This button will save your stored variables in the Hashmal config file.'
        )

        form.addRow('Add:', add_var_hbox)
        form.addRow(floated_buttons([self.auto_save_check, self.save_button]))
        return form
Example #11
0
    def __init__(self, main_window, tree, parent=None):
        super(InputsEditor, self).__init__(tree, parent)
        self.prev_tx = QLineEdit()
        self.prev_tx.setToolTip(
            'Transaction ID of the tx with the output being spent')
        self.prev_tx.setWhatsThis(
            'Use this field to specify the transaction that contains the output you\'re spending.'
        )

        self.prev_vout = AmountEdit()
        self.prev_vout.setToolTip('Output index of the previous transaction')
        self.prev_vout.setWhatsThis(
            'Use this field to specify the output you are spending of the previous transaction.'
        )

        self.script = ScriptEditor(main_window)
        self.script.setToolTip(
            'Script that will be put on the stack before the previous output\'s script.'
        )
        self.script.setWhatsThis(
            'Enter a script here. This script will be evaluated directly before the script of the output you are spending. Any values that are pushed onto the stack when this script finishes its execution are present when the output script is evaluated afterward.'
        )

        self.sequence = AmountEdit()
        self.sequence.setText('4294967295')
        self.sequence.setWhatsThis(
            'Use this field to specify the sequence value. It\'s likely that you should leave this as its default (maximum) value.'
        )
        maxify_input_sequence = QPushButton('Max')
        maxify_input_sequence.clicked.connect(
            lambda: self.sequence.setText('0xffffffff'))
        maxify_input_sequence.setWhatsThis(
            'This button will set the sequence to its default value.')

        for i in [self.prev_tx, self.prev_vout, self.script, self.sequence]:
            i.setFont(monospace_font)

        self.mapper.addMapping(self.prev_tx, 0)
        self.mapper.addMapping(self.prev_vout, 1, 'amount')
        self.mapper.addMapping(self.script, 2, 'humanText')
        self.mapper.addMapping(self.sequence, 3, 'amount')

        delete_button = QPushButton('Remove Input')
        delete_button.setToolTip('Remove this input from the transaction')
        delete_button.clicked.connect(self.do_delete)
        submit_button = QPushButton('Save')
        submit_button.setToolTip('Update input with the above data')
        submit_button.clicked.connect(self.do_submit)

        form = QFormLayout()
        form.setContentsMargins(0, 0, 0, 0)
        form.addRow('Previous Transaction: ', self.prev_tx)
        form.addRow('Previous Tx Output: ', self.prev_vout)
        form.addRow('Input script: ', self.script)
        seq_desc = QLabel(
            'Sequence is mostly deprecated.\nIf an input has a sequence that\'s not the maximum value, the transaction\'s locktime will apply.'
        )
        seq_desc.setWordWrap(True)
        form.addRow(seq_desc)
        form.addRow('Sequence: ', HBox(self.sequence, maxify_input_sequence))
        form.addRow(floated_buttons([delete_button, submit_button]))

        self.setLayout(form)
Example #12
0
    def create_inputs_tab(self):
        form = QFormLayout()
        self.inputs_tree = InputsTree()

        input_prev_tx = QLineEdit()
        input_prev_tx.setToolTip('Transaction ID of the tx with the output being spent')

        input_prev_vout = AmountEdit()
        input_prev_vout.setToolTip('Output index of the previous transaction')

        input_script = QTextEdit()
        input_script.setToolTip('Script that will be put on the stack before the previous output\'s script.')

        input_sequence = AmountEdit()
        input_sequence.setText('4294967295')
        maxify_input_sequence = QPushButton('Max')
        maxify_input_sequence.clicked.connect(lambda: input_sequence.setText('0xffffffff'))

        rm_input_edit = QSpinBox()
        rm_input_edit.setRange(0, 0)
        rm_input_button = QPushButton('Remove input')

        def add_input():
            try:
                outpoint = COutPoint(lx(str(input_prev_tx.text())), input_prev_vout.get_amount())
                in_script = Script.from_human(str(input_script.toPlainText()))
                new_input = CTxIn(outpoint, in_script.get_hex().decode('hex'), input_sequence.get_amount())
            except Exception as e:
                self.status_message(str(e), True)
                return
            else:
                self.inputs_tree.add_input(new_input)
                rm_input_edit.setRange(0, len(self.inputs_tree.get_inputs()) - 1)

        def rm_input():
            in_num = rm_input_edit.value()
            self.inputs_tree.model.takeRow(in_num)
            rm_input_edit.setRange(0, len(self.inputs_tree.get_inputs()) - 1)

        add_input_button = QPushButton('Add input')
        add_input_button.setToolTip('Add the above input')
        add_input_button.clicked.connect(add_input)

        rm_input_button.clicked.connect(rm_input)

        for i in [input_prev_tx, input_prev_vout, input_script, input_sequence]:
            i.setFont(monospace_font)

        form.addRow(self.inputs_tree)
        form.addRow(Separator())

        form.addRow('Previous Transaction:', input_prev_tx)
        form.addRow('Previous Tx Output:', input_prev_vout)
        form.addRow('Input script:', input_script)
        seq_desc = QLabel('Sequence is mostly deprecated.\nIf an input has a sequence that\'s not the maximum value, the transaction\'s locktime will apply.')
        seq_desc.setWordWrap(True)
        form.addRow(seq_desc)
        form.addRow('Sequence:', HBox(input_sequence, maxify_input_sequence))

        form.addRow(Separator())
        form.addRow(floated_buttons([add_input_button]))
        form.addRow('Remove input:', HBox(rm_input_edit, rm_input_button))

        w = QWidget()
        w.setLayout(form)
        return w
Example #13
0
    def create_outputs_tab(self):
        form = QFormLayout()
        self.outputs_tree = OutputsTree()

        output_value = QLineEdit()

        output_script = QTextEdit()
        output_script.setToolTip('Script that will be put on the stack after the input that spends it.')

        rm_output_edit = QSpinBox()
        rm_output_edit.setRange(0, 0)
        rm_output_button = QPushButton('Remove output')

        def add_output():
            try:
                val_str = str(output_value.text())
                value = 0
                if '.' in val_str:
                    value = int(float(val_str) * pow(10, 8))
                else:
                    value = int(val_str)
                out_script = Script.from_human(str(output_script.toPlainText()))
                new_output = CTxOut(value, out_script.get_hex().decode('hex'))
            except Exception as e:
                self.status_message(str(e), True)
                return
            else:
                self.outputs_tree.add_output(new_output)
                rm_output_edit.setRange(0, len(self.outputs_tree.get_outputs()) - 1)

        def rm_output():
            out_n = rm_output_edit.value()
            self.outputs_tree.model.takeRow(out_n)
            rm_output_edit.setRange(0, len(self.outputs_tree.get_outputs()) - 1)

        add_output_button = QPushButton('Add output')
        add_output_button.setToolTip('Add the above output')
        add_output_button.clicked.connect(add_output)

        rm_output_button.clicked.connect(rm_output)

        value_desc = QLabel('Include a decimal point if this value is not in satoshis.')
        value_desc.setWordWrap(True)

        for i in [output_value, output_script]:
            i.setFont(monospace_font)

        form.addRow(self.outputs_tree)
        form.addRow(Separator())

        form.addRow(value_desc)
        form.addRow('Value:', output_value)
        form.addRow('Output script:', output_script)

        form.addRow(Separator())
        form.addRow(floated_buttons([add_output_button]))
        form.addRow('Remove output:', HBox(rm_output_edit, rm_output_button))

        w = QWidget()
        w.setLayout(form)
        return w