<p><strong>As long as all selected transactions are valid, you may select any transactions you want.</strong></p>

<p>You should check that there are no double spends among the selected transactions and that you keep any transactions which build on each other in the correct order, i.e. if <code>TX B</code> spends an output of <code>TX A</code>, <code>TX B</code> has to be listed after <code>TX A</code> in the block if you select both.</p>

<p>Sorting them by fee rate (i.e. fee paid per data size or satoshi per byte) will greedily maximize the transaction fees that you collect per block, to optimize block usage while maximizing fee, you'd have to perhaps use a knapsack solver.</p>

<p>Priority was <a href="https://bitcoin.org/en/release/v0.12.0#relay-and-mining-priority-transactions" rel="nofollow noreferrer">turned off by default in Bitcoin Core 0.12.0</a>, I actually asked a few months ago whether any <a href="https://bitcoin.stackexchange.com/q/49226/5406">miners still select by priority</a>.</p>

CC BY-SA 3.0
2017-01-11T13:01:20.473Z
2017-01-11T13:01:20.473Z
2017-04-13T12:47:33.583Z
Murch
<p>According to <a href="http://chimera.labs.oreilly.com/books/1234000001802/ch08.html#_transaction_age_fees_and_priority" rel="nofollow noreferrer">Mastering Bitcoin. Mining - Transaction Age, Fees, and Priority</a>, miners sort transactions, using special parameter, called <em>priority</em>, which looks like</p>

<p><strong>Priority = Sum (Value of input * Input Age) / Transaction Size</strong></p>

<p>If the priority is greater than 57,600,000, it means that transaction is <em>high priority</em> and it will be written in the first 50 kb.</p>

<p>The question is: <strong>Is priority really necessary?</strong> I mean, if I'm a miner and I have e.g. 1000 unconfirmed transactions, is it ok to randomly choose 100 transactions and put them into the block just as it is? Without sorting by priority or fees?</p>

<p>Will it work out or I'll get <code>reject</code> message or something?</p>

<mining-theory><transaction-selection><coin-age-priority>
Is it OK not to sort transactions at all?
Sergey Potekhin
# Is it OK not to sort transactions at all?

(Asked by: username_0 on 2017-01-11)

According to [Mastering Bitcoin. Mining - Transaction Age, Fees, and Priority](http://chimera.labs.oreilly.com/books/1234000001802/ch08.html#_transaction_age_fees_and_priority), miners sort transactions, using special parameter, called *priority*, which looks like

**Priority = Sum (Value of input \* Input Age) / Transaction Size**

If the priority is greater than 57,600,000, it means that transaction is *high priority* and it will be written in the first 50 kb.

The question is: **Is priority really necessary?** I mean, if I'm a miner and I have e.g. 1000 unconfirmed transactions, is it ok to randomly choose 100 transactions and put them into the block just as it is? Without sorting by priority or fees?

Will it work out or I'll get `reject` message or something?

**Tags:** mining-theory, transaction-selection, coin-age-priority


---

## 1 answers

### Answer by username_1 on 2017-01-11. Score: 3 | Accepted answer

**As long as all selected transactions are valid, you may select any transactions you want.**

You should check that there are no double spends among the selected transactions and that you keep any transactions which build on each other in the correct order, i.e. if `TX B` spends an output of `TX A`, `TX B` has to be listed after `TX A` in the block if you select both.

Sorting them by fee rate (i.e. fee paid per data size or satoshi per byte) will greedily maximize the transaction fees that you collect per block, to optimize block usage while maximizing fee, you'd have to perhaps use a knapsack solver.

Priority was [turned off by default in Bitcoin Core 0.12.0](https://bitcoin.org/en/release/v0.12.0#relay-and-mining-priority-transactions), I actually asked a few months ago whether any [miners still select by priority](https://bitcoin.stackexchange.com/q/49226/5406).


---

