docs: def segwit_addr_decode(addr, hrp=bech32_prefix):
      """
      Decode a segwit address.
      Returns (version, hash_bin) on success
      Returns (None, None) on error
      """
      hrpgot, data = bech32_decode(addr)
      if hrpgot != hrp:
          return (None, None)
      decoded = convertbits(data[1:], 5, 8, False)
      if decoded is None or len(decoded) < 2 or len(decoded) > 40:
          return (None, None)
      if data[0] > 16:
          return (None, None)
      if data[0] == 0 and len(decoded) != 20 and len(decoded) != 32:
          return (None, None)
      return (data[0], ''.join([chr(x) for x in decoded]))