docs: def parse_multisig_redeemscript( redeem_script_hex ):
      """
      Given a redeem script (as hex), extract multisig information.
      Return m, list of public keys on success
      Return (None, None)
      """
      script_parts = []
      redeem_script_hex = str(redeem_script_hex)
  
      try:
          script_parts = btc_script_deserialize(redeem_script_hex)
      except:
          if os.environ.get("BLOCKSTACK_TEST") == "1":
              traceback.print_exc()
  
          log.error("Invalid redeem script %s" % redeem_script_hex)
          return None, None
  
      try:
          assert len(script_parts) > 2
          assert script_parts[-1] == OPCODE_VALUES['OP_CHECKMULTISIG']
          script_parts.pop(-1)
  
          # get n
          n = script_parts.pop(-1)
          pubkeys = []
  
          # get m
          m = script_parts.pop(0)
  
          for i in xrange(0, n):
              pubk = script_parts.pop(0)
              
              # must be a public key
              BitcoinPublicKey(pubk)
              pubkeys.append(pubk)
  
          assert len(script_parts) == 0, "script_parts = %s" % script_parts
          return (m, pubkeys)
      except Exception, e:
          if os.environ.get("BLOCKSTACK_TEST") == "1":
              traceback.print_exc()
  
          log.error("Invalid redeem script %s (parses to %s)" % (redeem_script_hex, script_parts))
          return (None, None)