Closed daira closed 5 years ago
I don't think so; (*data_len)
increments, but is used as a negative in the index to input
: input[(input_len - 1) - *data_len]
, so it counts backwards.
There is also a unit test for an HRP that includes a "1", which both the C and C++ code pass.
You're right, sorry for the invalid report.
https://github.com/sipa/bech32/blob/60848c2e9f214910d98636773fae103ea948be6f/ref/c/segwit_addr.c#L95-L99
https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32 says that the last '1' in the string is the HRP separator. The reference code is inconsistent with that and with Bitcoin Core.