<p>The structure of a transaction is documented in the <a href="https://en.bitcoin.it/wiki/Protocol_specification#tx" rel="nofollow">tx section of the Bitcoin protocol specification</a>.  To make the inputs, you need to find outputs from previous transactions that have not been spent yet, and you need to write a little <a href="https://en.bitcoin.it/wiki/Script" rel="nofollow">script</a> to unlock each output.</p>

<p>The script that you write will run first, and it will put some data on the stack in the script's execution environment.  Then the script that was embedded into the transaction's output will run, and it will evaluate whether your script supplied the right data.  The scripts of the outputs generally are pretty simple and only follow a couple of standard forms, so if you can recognize which form it is then you should be able to come up with an input script that satisfies it.  You might look at the <a href="https://github.com/bitcoin/bitcoin/blob/ae7e5d7cebd9466d0c095233c9273e72e88fede1/src/script.cpp#L1414" rel="nofollow">isStandard function</a> in Bitcoin Core to understand what scripts are standard.  The Solver class used there is problably the class that generates an input script for an output script; essentially it solves the puzzle of producing data that will be accepted by the output script.</p>

<p>I think if you follow the links above and look into it you should be able to figure out what is going on.</p>

CC BY-SA 3.0
2014-04-22T16:38:14.530Z
2014-04-22T16:38:14.530Z
David Grayson
<p>I'm wanting to send a raw TX, but i don't know how to come up with some of the parameters to the commands. What goes into the commands, what commands get used, and how to calculate anything that needs calculating. I know this needs to be done in the bitcoin command-line/console.  </p>

CC BY-SA 3.0
2014-04-22T16:32:42.543Z
I don't understand.  Are you trying to make a raw transaction yourself or are you trying to use a command-line tool written by someone else to do it?  Which tool?
David Grayson
CC BY-SA 3.0
2014-04-23T05:32:11.873Z
Bitcoin-Qt or BitcoinD, the official programs. A raw TX is a transaction made by hand.
Tyler
CC BY-SA 3.0
2014-04-23T15:34:50.383Z
What have you tried so far?  Did you find the name of the command to run?   Did you find the documentation?
David Grayson
<raw-transaction>
how to calculate the inputs to raw transactions?
Tyler
# how to calculate the inputs to raw transactions?

(Asked by: username_0 on 2014-04-22)

I'm wanting to send a raw TX, but i don't know how to come up with some of the parameters to the commands. What goes into the commands, what commands get used, and how to calculate anything that needs calculating. I know this needs to be done in the bitcoin command-line/console.

**Tags:** raw-transaction

> **Comments:**
> **username_1**: I don't understand.  Are you trying to make a raw transaction yourself or are you trying to use a command-line tool written by someone else to do it?  Which tool?  
> **username_0**: Bitcoin-Qt or BitcoinD, the official programs. A raw TX is a transaction made by hand.  
> **username_1**: What have you tried so far?  Did you find the name of the command to run?   Did you find the documentation?  

---

## 1 answers

### Answer by username_1 on 2014-04-22. Score: 1

The structure of a transaction is documented in the [tx section of the Bitcoin protocol specification](https://en.bitcoin.it/wiki/Protocol_specification#tx). To make the inputs, you need to find outputs from previous transactions that have not been spent yet, and you need to write a little [script](https://en.bitcoin.it/wiki/Script) to unlock each output.

The script that you write will run first, and it will put some data on the stack in the script's execution environment. Then the script that was embedded into the transaction's output will run, and it will evaluate whether your script supplied the right data. The scripts of the outputs generally are pretty simple and only follow a couple of standard forms, so if you can recognize which form it is then you should be able to come up with an input script that satisfies it. You might look at the [isStandard function](https://github.com/bitcoin/bitcoin/blob/ae7e5d7cebd9466d0c095233c9273e72e88fede1/src/script.cpp#L1414) in Bitcoin Core to understand what scripts are standard. The Solver class used there is problably the class that generates an input script for an output script; essentially it solves the puzzle of producing data that will be accepted by the output script.

I think if you follow the links above and look into it you should be able to figure out what is going on.


---

