<p>I want to create a raw transaction with python and i found the script 
Makes a transaction from the inputsoutputs is a list of [redemptionSatoshis, outputScript]</p>

<pre><code>def makeRawTransaction(outputTransactionHash, sourceIndex, scriptSig, outputs):

def makeOutput(data):redemptionSatoshis, outputScript = datareturn (struct.pack("&lt;Q", redemptionSatoshis).encode('hex') +'%02x' % len(outputScript.decode('hex')) + outputScript)

formattedOutputs = ''.join(map(makeOutput, outputs)) 
return ( "01000000" +  "01" + outputTransactionHash.decode('hex')[::-1].encode('hex') + 
outputTransactionHash struct.pack('&lt;L', sourceIndex).encode('hex') + '%02x' % 
len(scriptSig.decode('hex')) + scriptSig + "ffffffff" + "%02x" % len(outputs) +formattedOutputs + "00000000")
</code></pre>

CC BY-SA 3.0
2018-02-25T19:52:45.617Z
welcome to bitcoin.SE! Your post is a bit unformatted, as such it is not really clear, what you are asking. Anyhow, the way to create a tx is well described by amaclin's answer here: https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required?rq=1 - hope this helps.
pebwindkraft
CC BY-SA 3.0
2018-02-26T02:58:56.827Z
@pebwindkraft hope it's clear now!
Tailer
CC BY-SA 3.0
2018-02-26T20:45:35.727Z
Yup, one day I will learn as well, how to edit/correct the layout :-)
pebwindkraft
CC BY-SA 3.0
2018-03-02T17:13:26.773Z
Even with the edits, I don't understand what the question is.
Mine
<bitcoin-core><raw-transaction>
Creating a raw transaction, Please help
Donovan R. Palmer
# Creating a raw transaction, Please help

(Asked by: username_0 on 2018-02-25)

I want to create a raw transaction with python and i found the script
Makes a transaction from the inputsoutputs is a list of [redemptionSatoshis, outputScript]

```
def makeRawTransaction(outputTransactionHash, sourceIndex, scriptSig, outputs):

def makeOutput(data):redemptionSatoshis, outputScript = datareturn (struct.pack("<Q", redemptionSatoshis).encode('hex') +'%02x' % len(outputScript.decode('hex')) + outputScript)

formattedOutputs = ''.join(map(makeOutput, outputs)) 
return ( "01000000" +  "01" + outputTransactionHash.decode('hex')[::-1].encode('hex') + 
outputTransactionHash struct.pack('<L', sourceIndex).encode('hex') + '%02x' % 
len(scriptSig.decode('hex')) + scriptSig + "ffffffff" + "%02x" % len(outputs) +formattedOutputs + "00000000")

```

**Tags:** bitcoin-core, raw-transaction

> **Comments:**
> **username_1**: welcome to bitcoin.SE! Your post is a bit unformatted, as such it is not really clear, what you are asking. Anyhow, the way to create a tx is well described by amaclin's answer here: https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required?rq=1 - hope this helps.  
> **username_2**: @username_1 hope it's clear now!  
> **username_1**: Yup, one day I will learn as well, how to edit/correct the layout :-)  
> **username_3**: Even with the edits, I don't understand what the question is.  

---

## 0 answers

