Thanks very much for this!
fyi, I'm using it to generate BIP84/P2WPKH addresses from privatekeys for bitcoin, e.g.:
$ KEY="L2QQ7BHxpTwvi68BS9BcARM3W6UUbiJcLeUVnCcJ2wNLebGBwgHB"
$ bech32 2>&- -s 0 `echo ${KEY} | bx wif-to-public | bx bitcoin160`
bc1qnlj5pe9yzngat378vcezjc2c07r02k2rthqqyu
It would be cool if instead of passing hexdata as an argument it could be passed as stdin (possibly with hexdata arg specified as a hyphen, -, to indicate such), and to remove the 'data_len' output going to stderr. Then I could use:
$ echo ${KEY} | bx wif-to-public | bx bitcoin160 | bech32 -s 0 -