code: def encode(hrp, witver, witprog):
      
      ret = bech32_encode(hrp, [witver] + convertbits(witprog, 8, 5))
      if decode(ret) == (None, None):
          return None
      return ret
docs: Encode a segwit address.