I'm trying to iterate over all blocks, incl orphans, via the rpc api.
First, these are my assumptions. Please tell if these are correct:
- Orphaned blocks are valid blocks.
- Orphaned blocks contains valid transactions.
- The transactions in an orphaned blocks can only be found in that orphaned block.
In order to iterate over all blocks in the longest chain you could use these commands:
getblockcount
getblockhash
getblock
But what about all the orphans? They are not part of the longest chain, right? You can get any block if you know the hash with "getblock". But how do you discover the hash of the orphans in the first place?
Is there a way to discover the orphans via rpc?