<p>A miner chooses whatever transactions makes business sense to them. They don't have to include any transactions if they don't want to. They can make a block containing no transactions (other than the coinbase transaction that pays the miner the block reward).</p>
<p>Typically, as soon as a block has been published by someone else (or themselves), I'd expect a miner to obtain or build a block template that may or may not include a bunch of transactions waiting in its &quot;memory pool&quot; (mempool). Then the miner will run through trillions of different values for the nonce etc and for each value, compute the hash of the block to see if the resulting  hash is less than the current target.</p>
<p>But miners can start mining any time they like. The only constraint is that they just waste their time if they try to publish block number N after someone else already published a different block with block number N.</p>
<hr />
<blockquote>
<p><strong>The miner assembles N transactions into a block</strong></p>
</blockquote>
<p>That's basically true. Mostly.</p>
<blockquote>
<p><strong>(rather than creating a consensus for every single transaction).</strong></p>
</blockquote>
<p>Miners don't create consensus.</p>
<p>Miners could create a block for one transaction at a time if they wanted to.</p>
<blockquote>
<p><strong>when exactly the miner code decides to &quot;combine&quot;?</strong></p>
</blockquote>
<p>Whenever they want.</p>
<blockquote>
<p><strong>Does it wait until the list of transactions hit the block size limit (1 MB)?</strong></p>
</blockquote>
<p>No.</p>
<blockquote>
<p><strong>does it just wait X-minute?</strong></p>
</blockquote>
<p>No.</p>
<blockquote>
<p><strong>does it combine immediately as soon as it receives the transaction fees?</strong></p>
</blockquote>
<p>No.</p>
<p>Miners don't <em>receive</em> transaction fees. Certainly not in advance.</p>
<p>Miners <em>claim</em> transaction fees. They do this by creating a coinbase transaction that they include as the first transaction in a block. This transaction typically moves the transaction fee amounts into an address of the miner's wallet.</p>
<p>They can't spend that money unless everyone involved thinks their new block meets all the rules.</p>
<p>One rule is they can't spend that money until after another 100 blocks has been mined.</p>

CC BY-SA 4.0
2021-10-14T17:24:40.620Z
Thank you. Then is there any benefit to include more transactions thus longer chain? What if two nodes found nonce almost at the same time?
ldanfrustdsbflqbsdeedrustdf
CC BY-SA 4.0
2021-10-14T20:00:35.120Z
See [What happens if two miners mine the next block at the same time?](https://bitcoin.stackexchange.com/q/8172/13866) and [What would happen if two miners were mining two blocks with two different set of transactions?](https://bitcoin.stackexchange.com/q/72662/13866)
RedGrittyBrick
CC BY-SA 4.0
2021-10-14T16:25:55.630Z
2021-10-14T16:43:32.923Z
2021-10-14T16:43:32.923Z
RedGrittyBrick
<p>I need some help understanding the Bitcoin internal...</p>
<p>The basic idea is:</p>
<p>The miner assembles N transactions into a block (rather than creating a consensus for every single transaction). And hash those transactions for the consensus.</p>
<p>But, when exactly the miner code decides to &quot;combine&quot;? How long does the miner code wait until passing those transactions to a hash function?</p>
<p>Does it wait until the list of transactions hit the block size limit (1 MB)?</p>
<p>Or does it just wait X-minute?</p>
<p>Or does it combine immediately as soon as it receives the transaction fees?</p>
<p>The whitepaper says</p>
<blockquote>
<p>Each node collects new transactions into a block.</p>
</blockquote>
<blockquote>
<p>Although it would be possible to handle coins individually, it would be unwieldy to make a separate transaction for every cent in a transfer. To allow value to be split and combined, transactions contain multiple inputs and outputs.</p>
</blockquote>
<p>But does not explain how many it collects, or how long it waits for collection...</p>

<bitcoin-core><transactions><client>
When exactly does Bitcoin transaction batch happen?
ldanfrustdsbflqbsdeedrustdf
# When exactly does Bitcoin transaction batch happen?

(Asked by: username_0 on 2021-10-14)

I need some help understanding the Bitcoin internal...

The basic idea is:

The miner assembles N transactions into a block (rather than creating a consensus for every single transaction). And hash those transactions for the consensus.

But, when exactly the miner code decides to "combine"? How long does the miner code wait until passing those transactions to a hash function?

Does it wait until the list of transactions hit the block size limit (1 MB)?

Or does it just wait X-minute?

Or does it combine immediately as soon as it receives the transaction fees?

The whitepaper says

> Each node collects new transactions into a block.

> Although it would be possible to handle coins individually, it would be unwieldy to make a separate transaction for every cent in a transfer. To allow value to be split and combined, transactions contain multiple inputs and outputs.

But does not explain how many it collects, or how long it waits for collection...

**Tags:** bitcoin-core, transactions, client


---

## 1 answers

### Answer by username_1 on 2021-10-14. Score: 0 | Accepted answer

A miner chooses whatever transactions makes business sense to them. They don't have to include any transactions if they don't want to. They can make a block containing no transactions (other than the coinbase transaction that pays the miner the block reward).

Typically, as soon as a block has been published by someone else (or themselves), I'd expect a miner to obtain or build a block template that may or may not include a bunch of transactions waiting in its "memory pool" (mempool). Then the miner will run through trillions of different values for the nonce etc and for each value, compute the hash of the block to see if the resulting hash is less than the current target.

But miners can start mining any time they like. The only constraint is that they just waste their time if they try to publish block number N after someone else already published a different block with block number N.

---

> **The miner assembles N transactions into a block**

That's basically true. Mostly.

> **(rather than creating a consensus for every single transaction).**

Miners don't create consensus.

Miners could create a block for one transaction at a time if they wanted to.

> **when exactly the miner code decides to "combine"?**

Whenever they want.

> **Does it wait until the list of transactions hit the block size limit (1 MB)?**

No.

> **does it just wait X-minute?**

No.

> **does it combine immediately as soon as it receives the transaction fees?**

No.

Miners don't *receive* transaction fees. Certainly not in advance.

Miners *claim* transaction fees. They do this by creating a coinbase transaction that they include as the first transaction in a block. This transaction typically moves the transaction fee amounts into an address of the miner's wallet.

They can't spend that money unless everyone involved thinks their new block meets all the rules.

One rule is they can't spend that money until after another 100 blocks has been mined.

> **Comments:**
> **username_0**: Thank you. Then is there any benefit to include more transactions thus longer chain? What if two nodes found nonce almost at the same time?  
> **username_1**: See [What happens if two miners mine the next block at the same time?](https://bitcoin.stackexchange.com/q/8172/13866) and [What would happen if two miners were mining two blocks with two different set of transactions?](https://bitcoin.stackexchange.com/q/72662/13866)  

---

