Пример #1
0
def send(from_addr, to_addr, amount):
    bc = Blockchain()
    utxo_set = UTXOSet(bc)
    tx = UTXOTx(from_addr, to_addr, amount, utxo_set)

    inputs = []
    outputs = []

    for vin in tx.vin:
        ctxin = TXInput()
        ctxin._tx_id = vin.tx_id
        ctxin._vin = vin.vout
        ctxin._sig = vin.signature
        ctxin._public_key = vin.public_key

        inputs.append(ctxin)

    for vout in tx.vout:
        outputs.append(TXOutput(vout.value, vout.address))

    txnew = Transaction()
    txnew._id = tx.ID
    txnew._vin = inputs
    txnew._vout = outputs

    return txnew
Пример #2
0
    def _trimmed_copy(self):
        inputs = []
        outputs = []

        for vin in self.vin:
            ctxin = TXInput()
            ctxin._tx_id = vin.tx_id
            ctxin._vin = vin.vout 
            ctxin._sig = None 
            ctxin._public_key = None 

            inputs.append(ctxin)

        for vout in self.vout:
            outputs.append(TXOutput(vout.value, vout.address))

        txnew = Transaction()
        txnew._id = self.ID
        txnew._vin = inputs
        txnew._vout = outputs

        return txnew