code: func handleDecodeScript(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
  	c := cmd.(*btcjson.DecodeScriptCmd)
  
  	// Convert the hex script to bytes.
  	hexStr := c.HexScript
  	if len(hexStr)%2 != 0 {
  		hexStr = "0" + hexStr
  	}
  	script, err := hex.DecodeString(hexStr)
  	if err != nil {
  		return nil, rpcDecodeHexError(hexStr)
  	}
  
  	// The disassembled string will contain [error] inline if the script
  	// doesn't fully parse, so ignore the error here.
  	disbuf, _ := txscript.DisasmString(script)
  
  	// Get information about the script.
  	// Ignore the error here since an error means the script couldn't parse
  	// and there is no additinal information about it anyways.
  	scriptClass, addrs, reqSigs, _ := txscript.ExtractPkScriptAddrs(script,
  		s.cfg.ChainParams)
  	addresses := make([]string, len(addrs))
  	for i, addr := range addrs {
  		addresses[i] = addr.EncodeAddress()
  	}
  
  	// Convert the script itself to a pay-to-script-hash address.
  	p2sh, err := btcutil.NewAddressScriptHash(script, s.cfg.ChainParams)
  	if err != nil {
  		context := "Failed to convert script to pay-to-script-hash"
  		return nil, internalRPCError(err.Error(), context)
  	}
  
  	// Generate and return the reply.
  	reply := btcjson.DecodeScriptResult{
  		Asm:       disbuf,
  		ReqSigs:   int32(reqSigs),
  		Type:      scriptClass.String(),
  		Addresses: addresses,
  	}
  	if scriptClass != txscript.ScriptHashTy {
  		reply.P2sh = p2sh.EncodeAddress()
  	}
  	return reply, nil
  }
docs: // handleDecodeScript handles decodescript commands.