示例#1
0
def build_spending_tx(script_sig, credit_tx):
    tx = Transaction(version=1, locktime=0)
    txin = CMutableTxIn(CMutableOutPoint(credit_tx.GetHash(), 0), script_sig)
    tx.vin = [txin]
    txout = CMutableTxOut(0, Script())
    tx.vout = [txout]
    return tx
示例#2
0
def build_crediting_tx(script_pubkey):
    tx = Transaction(version=1, locktime=0)
    txin = CMutableTxIn()
    txin.scriptSig = Script.from_human('0x00 0x00')
    tx.vin = [txin]
    txout = CMutableTxOut(0, script_pubkey)
    tx.vout = [txout]
    return tx
示例#3
0
    def build_transaction(self):
        self.tx_widget.clear()
        self.sighash_widget.clear()
        self.tx = tx = Transaction()
        tx.nVersion = self.version_edit.get_amount()
        tx.vin = self.inputs_tree.get_inputs()
        tx.vout = self.outputs_tree.get_outputs()
        tx.nLockTime = self.locktime_edit.get_amount()

        for name, w in self.tx_field_widgets:
            if not name in [field[0] for field in tx.fields]:
                continue
            value = str(w.text())
            default = getattr(tx, name)
            if isinstance(default, int):
                value = w.get_amount()
            setattr(tx, name, value)

        self.raw_tx.setText(bitcoin.core.b2x(tx.serialize()))

        self.tx_widget.set_tx(tx)
        self.sighash_widget.set_tx(tx)