src/utils/bech32.js
function decode(str) {
  const [hrp, data] = deserialize(str);

  if (data.length === 0 || data.length > 65)
    throw new Error('Invalid bech32 data length.');

  if (data[0] > 16)
    throw new Error('Invalid bech32 version.');

  const version = data[0];
  const output = data;
  const hash = convert(data, output, 5, 8, -1, 1);

  if (hash.length < 2 || hash.length > 40)
    throw new Error('Invalid bech32 data length.');

  return new AddrResult(hrp, version, hash);
}
function decode(str) {
  const [hrp, data] = deserialize(str);

  if (data.length === 0 || data.length > 65)
    throw new Error('Invalid bech32 data length.');

  if (data[0] > 16)
    throw new Error('Invalid bech32 version.');

  const version = data[0];
  const output = data;
  const hash = convert(data, output, 5, 8, -1, 1);

  if (hash.length < 2 || hash.length > 40)
    throw new Error('Invalid bech32 data length.');

  return new AddrResult(hrp, version, hash);
}
function decode ( str ) { const [ hrp , data ] = deserialize ( str ) ; if ( data . length === 0 || data . length > 65 ) throw new Error ( 'Invalid bech32 data length.' ) ; if ( data [ 0 ] > 16 ) throw new Error ( 'Invalid bech32 version.' ) ; const version = data [ 0 ] ; const output = data ; const hash = convert ( data , output , 5 , 8 , - 1 , 1 ) ; if ( hash . length < 2 || hash . length > 40 ) throw new Error ( 'Invalid bech32 data length.' ) ; return new AddrResult ( hrp , version , hash ) ; }
Deserialize data from bech32 address.
@param {String} str
@returns {Object}
Deserialize data from bech32 address .