1

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?

2

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.

If on the other hand you're using the Bitcon Core JSON RPC then it's a simple matter of calling signrawtransaction (API) 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.

  • 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 Aug 2 '14 at 10:22
  • I finally found the block article I used to implement signing: righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html I'll add it to the answer as well. – cdecker Aug 2 '14 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.