hash consistencies in a search scenario

+2 votes
Is there a way to distinguish between hashes in the chain to know what type of  hash it is that was given in a search scenario?

For example to know a block hash starts with '00', transaction with 1 and address with 2?

Unless there is a API command that can help to determine what hash belongs where or what type of hash it is.
asked Aug 28, 2017 by RobertJ

1 Answer

+2 votes
Best answer

The space of addresses is completely separate from that of transaction and block hashes, so you should be able to detect addresses very reliably – they will almost certainly contain some non-hexadecimal characters and will be not be 64 character long.

As for distinguishing between blocks and transactions, MultiChain by default starts block hashes with 00, so that's a good heuristic. But 1 in 256 transactions (on average) will also start with this prefix. So your safest bet is just to try the hash as a block first with getblock, then fall back on a transaction – this is also very efficient.

answered Aug 28, 2017 by MultiChain
selected Aug 29, 2017 by RobertJ