I'm trying to write address validation in Python. According to the docs, Shelley addresses are encoded with bech32 and the first byte of the payload consists of header_type
(4 bits) and network_tag
(4 bits).
So, let's consider the following address:
addr1w8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcyjy7wx
In [2]: bech32.bech32_decode("addr1w8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcyjy7wx")
Out[2]:
('addr',
[14,
7,
1,
23,
22,
6,
[...]
The first byte of the payload is 14, which would mean network_tag = 14
and header_type = 0
. However, (a) the HRP doesn't contain the _test
suffix and (b) cardano-address
reports different network tag than my result does:
$ echo addr1w8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcyjy7wx | cardano-address address inspect
{
"spending_shared_hash": "c37b1b5dc0669f1d3c61a6fddb2e8fde96be87b881c60bce8e8d542f",
"stake_shared_hash_bech32": "stake_shared_vkh1cda3khwqv60360rp5m7akt50m6ttapacs8rqhn5w342z7p6v69g",
"address_style": "Shelley",
"network_tag": 1,
"spending_shared_hash_bech32": "addr_shared_vkh1cda3khwqv60360rp5m7akt50m6ttapacs8rqhn5w342z70dxhec",
"stake_reference": "none",
"stake_shared_hash": "c37b1b5dc0669f1d3c61a6fddb2e8fde96be87b881c60bce8e8d542f"
}
I guess I'm making some stupid mistake, but where?