Looking at the code referenced in bip-0173, specifically for example here: https://github.com/sipa/bech32/blob/master/ref/javascript/segwit_addr.js
function decode (hrp, addr) {
var dec = bech32.decode(addr);
if (dec === null || dec.hrp !== hrp || dec.data.length < 1 || dec.data[0] > 16) {
return null;
}
...
I understand that this is an error checking statement, but why check a (user?) inputted hrp vs the decoded hrp from bech32.decode?
Also I'm assuming that the "dec.data[0] > 16" check is to make sure that the byte at index zero doesn't exceed a value of 16, which would be invalid hex. Is this correct?