<p>Yes there is a total order over all confirmed transactions, namely the order over all the blocks by blockchain height, and internally by the order in which transactions appear in the block message. This block-internal order by the way is the same order which is also used to calculate the merkle tree root.</p>

<p>I would suggest calling <code>bitcoind getblockcount</code> to get the blockchain height. Then use <code>bitcoind getblockhash</code> for each block from 0 to that blockcount to retrieve each block and then traverse the <code>tx</code> part of the result, which should give you the transactions in the order they appear in the serialized block form (which is agreed upon by all nodes). Whether you count the block before or after its transactions is a matter of taste, but I'd suggest counting it after the transactions as they had to exist before the block was found.</p>

<p>So if you want to stop the process somewhere, simply remember the height of the block you last processed and the number of transactions you processed for that block, and you'll be ready to continue right where you left off.</p>

<p>Notice that there is no way to enumerate non-confirmed transactions, and orphan blocks. This is due to the fact that there simply is no unique ordering among them, which all nodes in the network would agree upon.</p>

CC BY-SA 3.0
2013-09-25T14:31:02.680Z
2013-09-25T14:31:02.680Z
cdecker
<p>Is it possible to enumerate all blocks/transactions, in order, using bitcoind API? The listsinceblock call seems to return the transactions without any ordering so assuming I get a very long list, I cannot process half of it, store last processed block hash and later ask again for transaction since that block.</p>

<transactions><bitcoind><bitcoin-core>
How to enumerate all blocks/transactions in order with bitcoind?
Szymon Pobiega
# How to enumerate all blocks/transactions in order with bitcoind?

(Asked by: username_0 on 2013-09-25)

Is it possible to enumerate all blocks/transactions, in order, using bitcoind API? The listsinceblock call seems to return the transactions without any ordering so assuming I get a very long list, I cannot process half of it, store last processed block hash and later ask again for transaction since that block.

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


---

## 1 answers

### Answer by username_1 on 2013-09-25. Score: 4 | Accepted answer

Yes there is a total order over all confirmed transactions, namely the order over all the blocks by blockchain height, and internally by the order in which transactions appear in the block message. This block-internal order by the way is the same order which is also used to calculate the merkle tree root.

I would suggest calling `bitcoind getblockcount` to get the blockchain height. Then use `bitcoind getblockhash` for each block from 0 to that blockcount to retrieve each block and then traverse the `tx` part of the result, which should give you the transactions in the order they appear in the serialized block form (which is agreed upon by all nodes). Whether you count the block before or after its transactions is a matter of taste, but I'd suggest counting it after the transactions as they had to exist before the block was found.

So if you want to stop the process somewhere, simply remember the height of the block you last processed and the number of transactions you processed for that block, and you'll be ready to continue right where you left off.

Notice that there is no way to enumerate non-confirmed transactions, and orphan blocks. This is due to the fact that there simply is no unique ordering among them, which all nodes in the network would agree upon.


---

