<p>If you have no trouble with Alice, Bob and Claudia know about each other, you could create a single transaction with 3 outputs, one for each of them. In such case they will all three get bitcoins, or all three would not get bitcoins (because actually it would be 1 transaction, which will get into blockchain, or would not).</p>
<h1>sendmany</h1>
<p>I can show you the way to make it with bitcoin-cli. For this you'll need full node running on your machine (<code>bitcoind</code>). This node must own your funds (privkeys for accounts with your funds must be in its wallet.dat). If this is the case, then you need <a href="https://bitcoin.org/en/developer-reference#sendmany" rel="nofollow noreferrer">sendmany</a> method.</p>
<p>Run:</p>
<pre><code># Unlock the wallet (If your wallet is unencrypted, skip this step)
bitcoin-cli walletpassphrase &quot;passphrase&quot; 10
# Send all funds to everybody you need
bitcoin-cli sendmany &quot;&quot; '{&quot;2N8hwP1WmJrFF5QWABn38y63uYLhnJYJYTF&quot;: 0.05, &quot;2N5zxMH53RX3JLWbV5csmZrAhWY1R7Fr1SA&quot;: 0.05}'
# Lock the wallet
bitcoin-cli walletlock
</code></pre>
<p>You'll get transaction id as the result of sendmany call:</p>
<pre><code>3a2addb48252889711a74f7e131816c8becfb112910342faefd17a8913ac2de7
</code></pre>
<p>(it is real transaction in bitcoin testnet)</p>
<p>To get more info about sendmany method, you can run <code>bitcoin-cli help sendmany</code>, you'll see the list of available params and examples of using it with curl. Or you can go to the <a href="https://bitcoin.org/en/developer-reference#rpcs" rel="nofollow noreferrer">official documentation</a></p>
<h1>createrawtransaction</h1>
<p>If you have access to bitcoin node, but this node does not have your funds, you can create new unsigned transaction using <code>createrawtransaction </code> method on the node, then sign this transaction in your wallet and send it, using <code>sendrawtransaction</code>.</p>

CC BY-SA 4.0
2018-07-12T13:47:53.790Z
Thanks a lot! Can you please guide me how to create 3 outputs from a single transaction?
Gagan
CC BY-SA 4.0
2018-07-12T13:45:41.290Z
2018-07-12T14:30:19.057Z
2020-06-16T11:10:03.350Z
MartinSolie
<p>AFAIK no... the proof, that transaction has gone through is it‘s appearance in a block. So it has a confirmation. This cannot be verified by other transactions. You would have to write a surrounding script, which verifies the confirmation status on the blockchain, and then triggers the other transactions.</p>

<p>It get‘s even more difficult in your scenario - what do you mean by simultaneously? If the first goes through, and the second not, then the first shall be revoked? Also impossible with the standard toolset. 
In general: why would a tx not go through? Based on a time limit? Or do you think more of double spent or similar?</p>

<p><strong>Update after comments section below:</strong></p>

<p>to have three outputs, the command from the bitcoin developer pages would become three pairs of address/bitcoin value:</p>

<pre><code>{
  "'$NEW_ADDRESS1'": 79.9999, 
  "'$NEW_ADDRESS2'": 10, 
  "'$NEW_ADDRESS3'": 1 
}
</code></pre>

<p>(lines are terminated by a comma or the final curly brace)</p>

CC BY-SA 4.0
2018-07-12T13:36:32.323Z
Hi @pebwindkraft, "what do you mean by simultaneously?" I mean I want to send all three transactions logically as a single transaction.
Gagan
CC BY-SA 4.0
2018-07-12T13:37:10.900Z
"If the first goes through, and the second not, then the first shall be revoked?" Yes, that's exactly what I mean.
Gagan
CC BY-SA 4.0
2018-07-12T13:41:14.327Z
"why would a tx not go through? Based on a time limit? Or do you think more of double spent or similar?" As I mentioned above that I want these three transactions to be submitted as a single transaction logically. What I was expecting here was to know if there was any in-built feature already available. But seems like it's not possible without scripting. Is that right?
Gagan
CC BY-SA 4.0
2018-07-12T21:19:57.067Z
I get your point, in bitcoin logic you would have one transaction with three outputs. Thats not batching... anyhow, creating a raw tx is described in the developer section of bitcoin.org (https://bitcoin.org/en/developer-examples#complex-raw-transaction). You would simply add a third address/amount pair... that is a standard way of creating tx in bitcoin, you can have even more than 3 outputs...
pebwindkraft
CC BY-SA 4.0
2018-07-12T13:17:58.873Z
2018-07-12T21:25:24.610Z
2018-07-12T21:25:24.610Z
pebwindkraft
<p><strong>Scenario:</strong>
Suppose that I have to make three transactions simultaneously to Alice, Bob and Claudia. Now the condition is if any one transaction fails the other two must also not go through. </p>

<p><strong>Query:</strong>
How can I achieve this in BTC blockchain? Is there any feature that BTC provide to batch transactions as one so that it's atomicity is maintained?</p>

<bitcoin-core><bitcoin-core-development><bip><payment-batching>
Is it possible to create batches of transactions in bitcoin blockchain?
Gagan
# Is it possible to create batches of transactions in bitcoin blockchain?

(Asked by: username_0 on 2018-07-12)

**Scenario:**
Suppose that I have to make three transactions simultaneously to Alice, Bob and Claudia. Now the condition is if any one transaction fails the other two must also not go through.

**Query:**
How can I achieve this in BTC blockchain? Is there any feature that BTC provide to batch transactions as one so that it's atomicity is maintained?

**Tags:** bitcoin-core, bitcoin-core-development, bip, payment-batching


---

## 2 answers

### Answer by username_1 on 2018-07-12. Score: 3 | Accepted answer

If you have no trouble with Alice, Bob and Claudia know about each other, you could create a single transaction with 3 outputs, one for each of them. In such case they will all three get bitcoins, or all three would not get bitcoins (because actually it would be 1 transaction, which will get into blockchain, or would not).

# sendmany

I can show you the way to make it with bitcoin-cli. For this you'll need full node running on your machine (`bitcoind`). This node must own your funds (privkeys for accounts with your funds must be in its wallet.dat). If this is the case, then you need [sendmany](https://bitcoin.org/en/developer-reference#sendmany) method.

Run:

```
# Unlock the wallet (If your wallet is unencrypted, skip this step)
bitcoin-cli walletpassphrase "passphrase" 10
# Send all funds to everybody you need
bitcoin-cli sendmany "" '{"2N8hwP1WmJrFF5QWABn38y63uYLhnJYJYTF": 0.05, "2N5zxMH53RX3JLWbV5csmZrAhWY1R7Fr1SA": 0.05}'
# Lock the wallet
bitcoin-cli walletlock

```

You'll get transaction id as the result of sendmany call:

```
3a2addb48252889711a74f7e131816c8becfb112910342faefd17a8913ac2de7

```

(it is real transaction in bitcoin testnet)

To get more info about sendmany method, you can run `bitcoin-cli help sendmany`, you'll see the list of available params and examples of using it with curl. Or you can go to the [official documentation](https://bitcoin.org/en/developer-reference#rpcs)

# createrawtransaction

If you have access to bitcoin node, but this node does not have your funds, you can create new unsigned transaction using `createrawtransaction`  method on the node, then sign this transaction in your wallet and send it, using `sendrawtransaction`.

> **Comments:**
> **username_0**: Thanks a lot! Can you please guide me how to create 3 outputs from a single transaction?  

---

### Answer by username_2 on 2018-07-12. Score: -1

AFAIK no... the proof, that transaction has gone through is it‘s appearance in a block. So it has a confirmation. This cannot be verified by other transactions. You would have to write a surrounding script, which verifies the confirmation status on the blockchain, and then triggers the other transactions.

It get‘s even more difficult in your scenario - what do you mean by simultaneously? If the first goes through, and the second not, then the first shall be revoked? Also impossible with the standard toolset.
In general: why would a tx not go through? Based on a time limit? Or do you think more of double spent or similar?

**Update after comments section below:**

to have three outputs, the command from the bitcoin developer pages would become three pairs of address/bitcoin value:

```
{
  "'$NEW_ADDRESS1'": 79.9999, 
  "'$NEW_ADDRESS2'": 10, 
  "'$NEW_ADDRESS3'": 1 
}

```

(lines are terminated by a comma or the final curly brace)

> **Comments:**
> **username_0**: Hi @username_2, "what do you mean by simultaneously?" I mean I want to send all three transactions logically as a single transaction.  
> **username_0**: "If the first goes through, and the second not, then the first shall be revoked?" Yes, that's exactly what I mean.  
> **username_0**: "why would a tx not go through? Based on a time limit? Or do you think more of double spent or similar?" As I mentioned above that I want these three transactions to be submitted as a single transaction logically. What I was expecting here was to know if there was any in-built feature already available. But seems like it's not possible without scripting. Is that right?  
> **username_2**: I get your point, in bitcoin logic you would have one transaction with three outputs. Thats not batching... anyhow, creating a raw tx is described in the developer section of bitcoin.org (https://bitcoin.org/en/developer-examples#complex-raw-transaction). You would simply add a third address/amount pair... that is a standard way of creating tx in bitcoin, you can have even more than 3 outputs...  

---

