code: def decode(addr):
      
      hrpgot, data = bech32_decode(addr)
      # if hrpgot != hrp:
      if hrpgot not in BECH32_VERSION_SET:
          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], decoded)
docs: Decode a segwit address.