<blockquote>
  <p>If we use this transaction as an example, how do we take the data from
  this and format it into a RAW signed transaction that I could send
  straight into the network without the need of a wallet?</p>
</blockquote>

<p>The referenced tx is already spent. So it cannot be re-used. Also you cannot reformat it into a RAW signed tx. There would be 2 steps required. First reformat into a "RAW UNSIGNED" tx, and then this would run through another set of commands to get it signed. Only then it could be sent to the network. 
In the example, there is a bit of data missing, I'll add quickly. It becomes clear with the two links below:</p>

<pre><code>version       01000000
Input(s):     1
Previous tx:  f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index:        0
script length 48
scriptSig:    304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d1090db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501
Sequence      00000000
Output:       1
Value:        5000000000
script length 19
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d OP_EQUALVERIFY OP_CHECKSIG
Locktime:     FFFFFFFF
</code></pre>

<p>now you have chosen a coinbase tx as reference, which adds some more difficulty, but ignoring this, then next step would be serialization. Instead of repeating, here are links to  <a href="https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required">amaclin's work</a> or <a href="https://bitcoin.stackexchange.com/questions/3374/how-to-redeem-a-basic-tx">runek's work</a>.</p>

<blockquote>
  <p>Also, after creating the signed RAW transaction, is it just hashed by
  SHA256 to create its hash ID or does creating the ID consist of other
  steps?</p>
</blockquote>

<p>No. Not that easy :-) See the link above, and what also gave me a very good hint was Ken Shirriff's blog "<a href="http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html" rel="nofollow noreferrer">Bitcoins the hard way</a>". There is many different data representation involved, including reversed hex and more, which adds layer(s) of complexity. </p>

<blockquote>
  <p>Lastly, what is scriptSig? I don't quiet understand scripts in general</p>
</blockquote>

<p>Basically it makes sure, that the condition to spend the transaction's funds are verified. This has been asked several times in bitcoin.SE, so I provide another link (see my answer further down):
<a href="https://bitcoin.stackexchange.com/questions/69062/why-does-bitcoin-uses-a-script-language/69077#69077">Why does Bitcoin uses a Script language?</a></p>

<p>And as said in this link, <a href="http://chimera.labs.oreilly.com/books/1234000001802/index.html" rel="nofollow noreferrer">the book from Andreas</a> answers all these questions very well. Really highly recommended.</p>

CC BY-SA 3.0
2018-03-07T08:11:08.317Z
I'm quite sure that the amaclin's provided link is a copy paste of the runek's previous answer though.
sr_gi
CC BY-SA 3.0
2018-03-07T07:07:29.077Z
2018-03-07T07:07:29.077Z
pebwindkraft
<p>You can sign the transaction hash data by pressing the "Sign" button by accessing the details of the transaction with tools such as Electrum. Then do not forget to say live broadcast.</p>

CC BY-SA 3.0
2018-03-06T21:20:21.037Z
2018-03-06T21:20:21.037Z
John McGrave
<p>Every transaction takes unspent outputs as inputs and creates new outputs. The creator of the transaction uses his private key to sign the transaction and nodes validate that transaction by using the public key of the creator.</p>

<p>But how excactly are transactions formated? I have seen this on the bitcoin wiki:</p>

<pre><code>Input:
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index: 0
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501

Output:
Value: 5000000000
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d
OP_EQUALVERIFY OP_CHECKSIG
</code></pre>

<p>If we use this transaction as an example, how do we take the data from this and format it into a RAW signed transaction that I could send straight into the network without the need of a wallet?</p>

<p>Also, after creating the signed RAW transaction, is it just hashed by SHA256 to create its hash ID or does creating the ID consist of other steps?</p>

<p>Lastly, what is scriptSig? I don't quiet understand scripts in general so if someone could give me a brief explanation of that as well I'd be grateful</p>

<p>Thanks in advance!</p>

<p>Fihdi</p>

<transactions><hash><script><signature><raw-transaction>
How is a transaction formated/signed?
fihdi
# How is a transaction formated/signed?

(Asked by: username_0 on 2018-03-06)

Every transaction takes unspent outputs as inputs and creates new outputs. The creator of the transaction uses his private key to sign the transaction and nodes validate that transaction by using the public key of the creator.

But how excactly are transactions formated? I have seen this on the bitcoin wiki:

```
Input:
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index: 0
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501

Output:
Value: 5000000000
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d
OP_EQUALVERIFY OP_CHECKSIG

```

If we use this transaction as an example, how do we take the data from this and format it into a RAW signed transaction that I could send straight into the network without the need of a wallet?

Also, after creating the signed RAW transaction, is it just hashed by SHA256 to create its hash ID or does creating the ID consist of other steps?

Lastly, what is scriptSig? I don't quiet understand scripts in general so if someone could give me a brief explanation of that as well I'd be grateful

Thanks in advance!

username_0

**Tags:** transactions, hash, script, signature, raw-transaction


---

## 2 answers

### Answer by username_1 on 2018-03-07. Score: 1 | Accepted answer

> If we use this transaction as an example, how do we take the data from
> this and format it into a RAW signed transaction that I could send
> straight into the network without the need of a wallet?

The referenced tx is already spent. So it cannot be re-used. Also you cannot reformat it into a RAW signed tx. There would be 2 steps required. First reformat into a "RAW UNSIGNED" tx, and then this would run through another set of commands to get it signed. Only then it could be sent to the network.
In the example, there is a bit of data missing, I'll add quickly. It becomes clear with the two links below:

```
version       01000000
Input(s):     1
Previous tx:  f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index:        0
script length 48
scriptSig:    304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d1090db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501
Sequence      00000000
Output:       1
Value:        5000000000
script length 19
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d OP_EQUALVERIFY OP_CHECKSIG
Locktime:     FFFFFFFF

```

now you have chosen a coinbase tx as reference, which adds some more difficulty, but ignoring this, then next step would be serialization. Instead of repeating, here are links to [amaclin's work](https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required) or [runek's work](https://bitcoin.stackexchange.com/questions/3374/how-to-redeem-a-basic-tx).

> Also, after creating the signed RAW transaction, is it just hashed by
> SHA256 to create its hash ID or does creating the ID consist of other
> steps?

No. Not that easy :-) See the link above, and what also gave me a very good hint was Ken Shirriff's blog "[Bitcoins the hard way](http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html)". There is many different data representation involved, including reversed hex and more, which adds layer(s) of complexity.

> Lastly, what is scriptSig? I don't quiet understand scripts in general

Basically it makes sure, that the condition to spend the transaction's funds are verified. This has been asked several times in bitcoin.SE, so I provide another link (see my answer further down):
[Why does Bitcoin uses a Script language?](https://bitcoin.stackexchange.com/questions/69062/why-does-bitcoin-uses-a-script-language/69077#69077)

And as said in this link, [the book from Andreas](http://chimera.labs.oreilly.com/books/1234000001802/index.html) answers all these questions very well. Really highly recommended.

> **Comments:**
> **username_2**: I'm quite sure that the amaclin's provided link is a copy paste of the runek's previous answer though.  

---

### Answer by username_3 on 2018-03-06. Score: 0

You can sign the transaction hash data by pressing the "Sign" button by accessing the details of the transaction with tools such as Electrum. Then do not forget to say live broadcast.


---

