<p>You can definitely do that. Generally speaking you can have any combination of n inputs and k outputs, both n and k being integers.</p>

<p>I'm assuming you want to know how to implement the signing process. The process to sign such a transaction is rather involved. You basically set the signatures on all inputs to an empty string and then iterate through the inputs, copying the transaction with empty signatures, inserting the script of the corresponding output in the signature's place and signing the resulting temporary transaction.</p>

<p>For the exact details see this very extensive explanation <a href="http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html" rel="nofollow">blog post</a>.</p>

<p>If on the other hand you're using the Bitcon Core JSON RPC then it's a simple matter of calling <code>signrawtransaction</code> (<a href="https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list" rel="nofollow">API</a>) and passing in a raw, i.e., unsigned transaction. Be careful though as there are no checks when signing this way and the resulting transaction does exactly what you told it to, e.g., it might claim 10 bitcoins and allocate only 1 on the outputs, leaving 9 bitcoins floating for transaction fees and you'll lose them.</p>

CC BY-SA 3.0
2014-08-02T10:22:01.877Z
Thanks for the answer. My concern is in fact, how to sign this transation. Being honest, I still don't get it. Do you have maybe some detailed materials to read on this topic? Any chunk of code maybe?
Rabur
CC BY-SA 3.0
2014-08-02T15:25:11.540Z
I finally found the block article I used to implement signing: http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html I'll add it to the answer as well.
cdecker
CC BY-SA 3.0
2014-07-30T12:46:31.860Z
2014-08-02T15:26:35.590Z
2014-08-02T15:26:35.590Z
cdecker
<p>Is it possible to create a transaction with 2txin and 2txout? If it is possible, then how does one sign this transaction?    </p>

<p>Or do I have to create two separate transactions? 1txin 1txout and 1txin 2txout?</p>

<transactions><signature><raw-transaction>
Is it possible to create a transaction with 2txin and 2txout?
Rabur
# Is it possible to create a transaction with 2txin and 2txout?

(Asked by: username_0 on 2014-07-30)

Is it possible to create a transaction with 2txin and 2txout? If it is possible, then how does one sign this transaction?

Or do I have to create two separate transactions? 1txin 1txout and 1txin 2txout?

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


---

## 1 answers

### Answer by username_1 on 2014-07-30. Score: 3 | Accepted answer

You can definitely do that. Generally speaking you can have any combination of n inputs and k outputs, both n and k being integers.

I'm assuming you want to know how to implement the signing process. The process to sign such a transaction is rather involved. You basically set the signatures on all inputs to an empty string and then iterate through the inputs, copying the transaction with empty signatures, inserting the script of the corresponding output in the signature's place and signing the resulting temporary transaction.

For the exact details see this very extensive explanation [blog post](http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html).

If on the other hand you're using the Bitcon Core JSON RPC then it's a simple matter of calling `signrawtransaction` ([API](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list)) and passing in a raw, i.e., unsigned transaction. Be careful though as there are no checks when signing this way and the resulting transaction does exactly what you told it to, e.g., it might claim 10 bitcoins and allocate only 1 on the outputs, leaving 9 bitcoins floating for transaction fees and you'll lose them.

> **Comments:**
> **username_0**: Thanks for the answer. My concern is in fact, how to sign this transation. Being honest, I still don't get it. Do you have maybe some detailed materials to read on this topic? Any chunk of code maybe?  
> **username_1**: I finally found the block article I used to implement signing: http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html I'll add it to the answer as well.  

---

