<p>I am assuming you want to accomplish something akin to what SatoshiDice does. Here is how it can be done, using API calls with the Bitcoin-Qt/bitcoind client:</p>

<ol>
<li><p><code>listunspent</code> - you get the list of all unspent transactions</p></li>
<li><p>You determine which ones you want to spend</p></li>
<li><p>You use <code>createrawtransaction</code> to create your inputs / outputs, taking <code>txid</code> and <code>vout</code> from the list of transactions that you have that are playing, as well as a list of transactions that constitute a "money supply" for you.</p></li>
<li><p>Use <code>signrawtransaction</code> to sign the created transaction</p></li>
<li><p>Use <code>sendrawtransaction</code> to send the signed transaction</p></li>
</ol>

<p>That should be pretty much it. I have implemented some of that code myself and it is pretty easy once you get a hang of it all.</p>

CC BY-SA 3.0
2013-03-18T17:49:29.737Z
One bit of caution -- in the raw transaction, any inputs used that are not fully spent go to the miner.  So be very careful when composing raw transactions.
Stephen Gornick
CC BY-SA 3.0
2013-07-29T14:12:45.107Z
How about fee calculation?
Shamoon
CC BY-SA 3.0
2013-07-29T15:26:15.600Z
@Shamoon http://bitcoinfees.com/ - you base them on the number of inputs and outputs.
ThePiachu
CC BY-SA 3.0
2013-03-07T12:56:45.740Z
2013-03-18T17:47:18.947Z
2013-03-18T17:47:18.947Z
ThePiachu
<p>A good way to see this (and also a non-automated method to do this) is available through BrainWallet:</p>

<ul>
<li><a href="http://brainwallet.org/#tx" rel="nofollow">http://brainwallet.org/#tx</a></li>
</ul>

CC BY-SA 3.0
2013-03-18T17:50:41.437Z
One bit of caution -- in the raw transaction, any inputs used that are not fully spent go to the miner.  So be very careful when composing raw transactions.
Stephen Gornick
CC BY-SA 3.0
2013-03-18T17:50:19.423Z
2013-03-18T17:50:19.423Z
Stephen Gornick
<p>Due to complete lack of documentation on the subject, how would the pseucode for creating a transaction look using the following functions: <code>createrawtransaction</code> <code>signrawtransaction</code> and <code>sendrawtransaction</code>.</p>

<p>I receive the user transaction for incoming coins on IncomingTxID, when I create a raw transction I want to include at least some of those coins so if they won't confirm, neither will his payout.</p>

CC BY-SA 3.0
2012-11-26T17:37:21.227Z
Related: [C# API for Bitcoin](http://bitcoin.stackexchange.com/q/5461/1878)
makerofthings7
CC BY-SA 3.0
2017-11-28T19:53:19.737Z
How to do this is documented in [_Mastering Bitcoin_ (1st ed.), §"Using Bitcoin Core’s JSON-RPC API from the Command Line"](http://chimera.labs.oreilly.com/books/1234000001802/ch03.html#_using_bitcoin_core_8217_s_json_rpc_api_from_the_command_line), §§"Creating, Signing, and Submitting Transactions Based on Unspent Outputs".
Geremia
<development><bitcoind><json-rpc>
Manually creating transactions
user1841964
# Manually creating transactions

(Asked by: username_0 on 2012-11-26)

Due to complete lack of documentation on the subject, how would the pseucode for creating a transaction look using the following functions: `createrawtransaction` `signrawtransaction` and `sendrawtransaction`.

I receive the user transaction for incoming coins on IncomingTxID, when I create a raw transction I want to include at least some of those coins so if they won't confirm, neither will his payout.

**Tags:** development, bitcoind, json-rpc

> **Comments:**
> **username_1**: Related: [C# API for Bitcoin](http://bitcoin.stackexchange.com/q/5461/1878)  
> **username_2**: How to do this is documented in [_Mastering Bitcoin_ (1st ed.), §"Using Bitcoin Core’s JSON-RPC API from the Command Line"](http://chimera.labs.oreilly.com/books/1234000001802/ch03.html#_using_bitcoin_core_8217_s_json_rpc_api_from_the_command_line), §§"Creating, Signing, and Submitting Transactions Based on Unspent Outputs".  

---

## 2 answers

### Answer by username_3 on 2013-03-07. Score: 3

I am assuming you want to accomplish something akin to what SatoshiDice does. Here is how it can be done, using API calls with the Bitcoin-Qt/bitcoind client:

1. `listunspent` - you get the list of all unspent transactions
2. You determine which ones you want to spend
3. You use `createrawtransaction` to create your inputs / outputs, taking `txid` and `vout` from the list of transactions that you have that are playing, as well as a list of transactions that constitute a "money supply" for you.
4. Use `signrawtransaction` to sign the created transaction
5. Use `sendrawtransaction` to send the signed transaction

That should be pretty much it. I have implemented some of that code myself and it is pretty easy once you get a hang of it all.

> **Comments:**
> **username_4**: One bit of caution -- in the raw transaction, any inputs used that are not fully spent go to the miner.  So be very careful when composing raw transactions.  
> **username_5**: How about fee calculation?  
> **username_3**: @username_5 http://bitcoinfees.com/ - you base them on the number of inputs and outputs.  

---

### Answer by username_4 on 2013-03-18. Score: 2

A good way to see this (and also a non-automated method to do this) is available through BrainWallet:

* <http://brainwallet.org/#tx>

> **Comments:**
> **username_4**: One bit of caution -- in the raw transaction, any inputs used that are not fully spent go to the miner.  So be very careful when composing raw transactions.  

---

